Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
WNetGetUser
Message
From
15/05/2001 19:37:25
Cheryl Qualset
Qualset Computer Consulting
Davis, California, United States
 
 
To
All
General information
Forum:
Visual Basic
Category:
Windows API functions
Title:
WNetGetUser
Miscellaneous
Thread ID:
00507628
Message ID:
00507628
Views:
68
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.
Next
Reply
Map
View

Click here to load this message in the networking platform