
Cant get LogonUser() to work in VB (Win32 API)
If you're trying to find out the logged on user name, then I believe the API
call you're looking for is "GetUserName"
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer as String, nSize as Long) as Long
Public Function LogonUser() as String
dim sBuffer as String * 255
dim lBufLen as Long
dim lRet as Long
lBufLen = 255
lRet = GetUserName( sBuffer, lBufLen)
LoginUser = sBuffer
end function
Quote:
>I can't seem to get the Win32 LogonUser() function to work from in VB. No
>matter what I pass it, the return value is always 0. GetLastError() always
>returns 0 as well. I have given my account "Act as part of the operating
>system" privledge... is there anything I might be missing???
>Thanks.
>Sean Hignett