Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
C# Helper...
 
XML RSS Feed
Follow VBHelper on Twitter
 
 
MSDN Visual Basic Community
 
 
 
 
 
TitleGet the user's name
Keywordsusername, user name, GetUserName
CategoriesWindows
 
Use the GetUserName API function.
 
' 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
 
 
Copyright © 1997-2010 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated