by Ayan Chaudhuri (8 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 5.0
Difficulty: Unknown Difficulty
Originally Published: Sat 2nd March 2002
Date Added: Mon 8th February 2021
Rating: (1 Votes)
Display the name of the user currently logged on.
Dim slength As Long
Dim retval As Long
Private Sub Command1_Click()
username = Space(255)
slength = 255
retval = GetUserName(username, slength) ' slength is now the length of the returned string
username = Left(username, slength - 1) ' extract the returned info from the buffer
Text1 = "The name of the current user is " + username
End Sub