' Return the user's name.
Private Function UserName() As String
Const UNLEN = 256 ' Max user name length.
Dim user_name As String
Dim name_len As Long
user_name = Space$(UNLEN + 1)
name_len = Len(user_name)
If GetUserName(user_name, name_len) = 0 Then
UserName = "<unknown>"
Else
UserName = Left$(user_name, name_len - 1)
End If
End Function
|