How can I find Current User in VB? Which key in registry tells?
I tried to find it in the registry but always
and all the time, I got:
default user
It gives right all the time but when the policy
is set in NT for default user, then the problem
occurs.
Is there any other way or key to find out??
A problem stays like a challenge till
I find the solution to it.
Re: How can I find Current User in VB? Which key in registry tells?
better use the GetUserName API.
Re: How can I find Current User in VB? Which key in registry tells?
sample
private Declare Function GetUserNameA Lib "advapi32.dll" (byval strUser as string, byref lLen as Long) as Boolean
public Function CurrentUser() as string
Dim strBuffer as string * 255
Dim lLen as Long
lLen = len(strBuffer)
If GetUserNameA(strBuffer, lLen) then
CurrentUser = UCase$(Left$(strBuffer, lLen - 1))
else
CurrentUser = ""
End If
End Function
usage:
msgbox "Current user: " & CurrentUser()