|
-
November 30th, 1999, 03:20 AM
#1
NT User
Hi everybody
How can I get the Windows NT Login of the current user in my app?
Fzz
-
November 30th, 1999, 03:28 AM
#2
Re: NT User
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
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|