VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



Get the logged on username from Windows 95/98/NT

by Ryan Hartman (2 Submissions)
Category: Windows API Call/Explanation
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (38 Votes)

Get the logged on username from Windows 95/98 and NT

API Declarations
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal
lpBuffer As String, nSize As Long) As Long
'inl as 1

Rate Get the logged on username from Windows 95/98/NT

gsUserId = ClipNull(GetUser())
Function GetUser() As String
 Dim lpUserID As String
 Dim nBuffer As Long
 Dim Ret As Long
 lpUserID = String(25, 0)
 nBuffer = 25
 Ret = GetUserName(lpUserID, nBuffer)
 If Ret Then
 GetUser$ = lpUserID$
 End If
End Function
Function ClipNull(InString As String) As String
 Dim intpos As Integer
 If Len(InString) Then
 intpos = InStr(InString, vbNullChar)
 If intpos > 0 Then
 ClipNull = Left(InString, intpos - 1)
 Else
 ClipNull = InString
 End If
 End If
End Function

Download this snippet    Add to My Saved Code

Get the logged on username from Windows 95/98/NT Comments

No comments have been posted about Get the logged on username from Windows 95/98/NT. Why not be the first to post a comment about Get the logged on username from Windows 95/98/NT.

Post your comment

Subject:
Message:
0/1000 characters