Get User Name.

This is a small but useful code to get the user’s login name from the system.Whenever we make windows apps.It is always not good in addressing the user as guest,user etc.Try..for example this code and address them by the name of what they have logged on.
‘…………Declarations…………………………………………………..

Private Declare Function GetUserName Lib “Advapi32″ Alias “GetUserNameA” (ByVal lpBuffer As String, nSize As Long) As Long

‘…………Function…………………………………………………..

Public Function GetLoginName() As Boolean
Dim s_LoginName as string
s_LoginName = String(20, Chr(0))
GetLoginName = GetUserName(s_LoginName, 20)
End Function

Hope this code will be of great use.

Leave a Comment

Name: (Required)

E-mail: (Required)

Website:

Comment: