It appears you have not yet registered with DEVPPL. To register please click here... (it's fast, easy and free!)

Forum

Log In Sponsors
Board index Programming Visual Basic Forum

getting windows username

Moderator: dafunkymunky

getting windows username

Postby pfogle on Thu Jan 25, 2007 11:12 am

Hi,
does anyone know how you pick up the username from the windows login in a VB6 app? I want to identify the user in a log file.

thanks
Phil
pfogle
 
Posts: 0
Joined: Thu Jan 25, 2007 11:07 am
Location: LONDON UK

Re: getting windows username

Postby amino0o on Thu Jun 28, 2007 11:39 pm

pfogle wrote:Hi,
does anyone know how you pick up the username from the windows login in a VB6 app? I want to identify the user in a log file.

thanks
Phil


Yup! Based on functions...




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

Public Function localUserName() As String
Dim m_myBuf As String * 25
Dim m_Val As Long, UserName As String

m_Val = GetUserName(m_myBuf, 25)
localUserName = Left(m_myBuf, InStr(m_myBuf, Chr(0)) - 1)
' YAYY i got the fokin user name to current
' logged on user!!!
' username = localUserName
End Function



put that code in the declarations..
now the loggod on user name would be
localUserName

so if u typed..

text1.text = localUserName

ir will come up with the logged on user..





amino0o
amino0o
 
Posts: 6
Joined: Thu Jun 28, 2007 11:11 pm


Who is online

Users browsing this forum: No registered users and 2 guests