Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
WNetGetUser
Message
 
À
15/05/2001 19:37:25
Cheryl Qualset
Qualset Computer Consulting
Davis, Californie, États-Unis
Information générale
Forum:
Visual Basic
Catégorie:
Fonctions API de Windows
Titre:
Divers
Thread ID:
00507628
Message ID:
00507649
Vues:
9
>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.


See the FAQ! A working example is waiting for you at http://www.levelextreme.com/wconnect/wc.dll?UniversalThread~2,33,Forum=21,29,758
Éric Moreau, MCPD, Visual Developer - Visual Basic MVP
Conseiller Principal / Senior Consultant
Moer inc.
http://www.emoreau.com
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform