CurUserName

By | 2002-06-01

Get the current username from Windows

Original Author: MAGiC MANiAC^mTo

Inputs

Dim sStr1$
sStr1 = CurUserName()

Returns

( The current username from Windows )
sStr1 = “MAGiC MANiAC^mTo”

Code

' 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

Author: dwirch

Derek Wirch is a seasoned IT professional with an impressive career dating back to 1986. He brings a wealth of knowledge and hands-on experience that is invaluable to those embarking on their journey in the tech industry.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.