Home
Search
 
What's New
Index
Books
Links
Q & A
Newsletter
Banners
 
Feedback
Tip Jar
 
 
 
 
 
 
 
 
Old Pages
 
Old Index
Site Map
What's New
 
Books
How To
Tips & Tricks
Tutorials
Stories
Performance
Essays
Links
Q & A
New in VB6
Free Stuff
Pictures
 
 
 
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-2003 Rocky Mountain Computer Consulting, Inc.   All rights reserved.
  Updated