VBcoders Guest



Don't have an account yet? Register
 


Forgot Password?



CurUserName

by MAGiC MANiAC^mTo (7 Submissions)
Category: String Manipulation
Compatability: Visual Basic 3.0
Difficulty: Advanced
Date Added: Wed 3rd February 2021
Rating: (6 Votes)

Get the current username from Windows

Inputs
Dim sStr1$ sStr1 = CurUserName()
Code Returns
( The current username from Windows ) sStr1 = "MAGiC MANiAC^mTo"

Rate CurUserName

' Get the current username from Windows
' Coded By MAGiC MANiAC^mTo
' More Examples At: http://home.kabelfoon.nl/~mto/
'
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" _ (ByVal lpBuffer As String, nSize As Long) As Long
Function CurUserName$()
 Dim sTmp1$
 sTmp1 = Space$(512)
 GetUserName sTmp1, Len(sTmp1)
 CurUserName = Trim$(sTmp1)
End Function

Download this snippet    Add to My Saved Code

CurUserName Comments

No comments have been posted about CurUserName. Why not be the first to post a comment about CurUserName.

Post your comment

Subject:
Message:
0/1000 characters