Find Windows UserName
API Declarations
'Email:[email protected]
'Location:Iran-Mazandaran-Tonekabon
'*****************************************
'Add 1CommandButton and 1Label to form
Private Declare Function GetUserNameA Lib "advapi32.dll" (ByVal lpBuffer As String, nSize As Long) As Long
Public Function GetUserName() As String
Dim UN As String * 255
Call GetUserNameA(UN, 255)
GetUserName = Left$(UN, InStr(UN, Chr$(0)) - 1)
End Function