How can i get the name of the current user logged in windows?? Please reply if you know...
Thanks in advance..
Printable View
How can i get the name of the current user logged in windows?? Please reply if you know...
Thanks in advance..
You can use GetUserName API.
Code:Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim lngRet As Long
Dim strUser As String
strUser = Space(125)
lngRet = GetUserName(strUser, Len(strUser))
If lngRet Then
MsgBox "UserName: " & strUser
End If
End Sub
Text1.Text = "Username: " & Environ$("USERNAME")
that's it. good luck.
Michael