|
-
Feb 23rd, 2001, 05:22 AM
#1
Thread Starter
Addicted Member
Hi friends,
Im new to API. I want to know the user name who has logged in the machine. What API should I use?
Pls help!!!
Cheers
Parasuraman
-
Feb 23rd, 2001, 05:33 AM
#2
Frenzied Member
Use the GetUserName API:
Code:
Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
-
Feb 23rd, 2001, 05:42 AM
#3
Addicted Member
Since you are new to API stuff I add this too..
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
Private Sub Your_Sub()
Dim strUSerName As String
'Create a buffer
strUserName = String(100, Chr$(0))
'Get the username
GetUserName strUserName, 100
'strip the rest of the buffer
strUserName = Left$(strUserName, InStr(strUserName, Chr$(0)) - 1)
MsgBox "Hello " + strUserName
End Sub
If you can't pronounce my name, call me GURU 
-
Feb 23rd, 2001, 06:00 AM
#4
Thread Starter
Addicted Member
Thanx alot CyeberCarsten and Kumar
Its working excellent.
Thanx alot again
Parasuraman
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
|