VB icon

95/NT username

Submitted on: 1/1/2015 8:41:00 AM
By: Newsgroup Posting (from psc cd)  
Level: Not Given
User Rating: By 6 Users
Compatibility: VB 4.0 (32-bit), VB 5.0, VB 6.0
Views: 4230
     95/NT username "Joseph P. Fisher"

Windows API/Global Declarations:

Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
'Windows API/Global Declarations for :95/NT username
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal
lpBuffer As String, nSize As Long) As Long
Can't Copy and Paste this?
Click here for a copy-and-paste friendly version of this code!
' Name: 95/NT username
' Description:95/NT username
"Joseph P. Fisher" <jfisher@cellone.net>
' By: Newsgroup Posting (from psc cd)

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

Other 14 submission(s) by this author


Report Bad Submission
Use this form to tell us if this entry should be deleted (i.e contains no code, is a virus, etc.).
This submission should be removed because:

Your Vote

What do you think of this code (in the Not Given category)?
(The code with your highest vote will win this month's coding contest!)
Excellent  Good  Average  Below Average  Poor (See voting log ...)

Other User Comments

 There are no comments on this submission.

Add Your Feedback
Your feedback will be posted below and an email sent to the author. Please remember that the author was kind enough to share this with you, so any criticisms must be stated politely, or they will be deleted. (For feedback not related to this particular code, please click here instead.)

To post feedback, first please login.