visual fzz
November 30th, 1999, 02:20 AM
Hi everybody
How can I get the Windows NT Login of the current user in my app?
Fzz
How can I get the Windows NT Login of the current user in my app?
Fzz
|
Click to See Complete Forum and Search --> : NT User visual fzz November 30th, 1999, 02:20 AM Hi everybody How can I get the Windows NT Login of the current user in my app? Fzz Chris Eastwood November 30th, 1999, 02:28 AM I always found the GetUserName() API call worked fine for me (there are other calls you can use). Paste the following code into a form : option Explicit private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (byval lpBuffer as string, nSize as Long) as Long private Sub Form_Load() Dim sBuffer as string Dim lRet as Long Dim sUserName as string ' ' Fill the buffer with char(0) ' sBuffer = string$(255, vbNullChar) lRet = GetUserName(sBuffer, 255) If lRet = 1 then sUserName = Left$(sBuffer, InStr(sBuffer, vbNullChar) - 1) else sUserName = "Unknown - error" End If MsgBox sUserName End Sub Chris Eastwood CodeGuru - the website for developers http://codeguru.developer.com/vb codeguru.com
Copyright Internet.com Inc., All Rights Reserved. |