Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WNetGetUser
Message
De
15/05/2001 19:37:25
Cheryl Qualset
Qualset Computer Consulting
Davis, Californie, États-Unis
 
 
À
Tous
Information générale
Forum:
Visual Basic
Catégorie:
Fonctions API de Windows
Titre:
WNetGetUser
Divers
Thread ID:
00507628
Message ID:
00507628
Vues:
67
I just want the user's login name.

I have a declaration for WNetGetUser as follows:
private declare function WNetGetUser lib "mpr.dll" alias "WNetGetUserA" (byval lpName as string, byval lpUserName as string, lpnLength as long) as long

then in a button click method:

dim lLen, result as long
dim sName, sBuffer as string
lLen = 255
sBuffer = space$(lLen) 'I have tried string(lLen, vbNullChar) also, same results
result = WNetGetUser(sName, sBuffer, lLen)

here the result is 0, but string is unchanged
I tried assigning "" or vbNullChar to sName and got result of 234

When I do the following in FoxPro, I get the user name I expect:

declare integer WNetGetUser in WIN32API string lpDeviceName, string lpUserNameBuffer, integer @BufferLength
lcBuffer = rep(chr(0), 256)
lnBufSize = 256

if WNetGetUser(0, @lcBuffer, @lnBufSize) = 0
return alltrim(strtran(left(lcBuffer, lnBufSize -1), chr(0))
endif

Can anyone help me?

PS I've not had success with GetComputerName or GetUserName, either.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform