Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal Buffer As String, ByRef Size As Long) As Long
Sub Main()
Dim Buffer As String * 255
Dim Result As Long
Dim Length As Long
Length = 255
Result = GetUserName(Buffer, Length)
If Length > 0 Then UserName = Left(Buffer, Length - 1)
End Sub