VBcoders Guest

Don't have an account yet? Register

Forgot Password?

95/NT username

by Newsgroup Posting (15 Submissions)
Category: Windows System Services
Compatability: Visual Basic 3.0
Difficulty: Unknown Difficulty
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

95/NT username
"Joseph P. Fisher"

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

Rate 95/NT username

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)
    ClipNull = InString
   End If
  End If
End Function

Download this snippet    Add to My Saved Code

95/NT username Comments

No comments have been posted about 95/NT username. Why not be the first to post a comment about 95/NT username.

Post your comment

0/1000 characters