Get user name using API
This API code will get the user name of the user. Start a new project and place a label
and command button on a form.
==========================================================
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _
(ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Command1_Click()
Dim getName As String
Dim nmSize As Long
getName = Space(255)
nmSize = 255
Call GetUserName(getName, nmSize - 1)
getName = RTrim(getName)
Label1 = getName
End Sub