|
-
Apr 23rd, 2000, 07:15 PM
#1
Thread Starter
Addicted Member
Very Urgent - Get User ID
Hi ...
Does anyone know how to get User ID
from NT/Novell using API ?
Pls let me know.
Thank you
Keiko
-
Apr 24th, 2000, 02:24 AM
#2
This is what I did
Private Sub GetLoginName()
Dim lRetVal as Long 'result of the API functions
Dim hKey as Long 'Handle of opened key
Dim vValue As Variant 'Setting of queried value
Dim vValue2 As Variant 'Setting of queried value
lRetVal = RegOpenKeyEx(HKEY_Local_Machine, "network\logon", 0, KEY_ALL_ACCESS, hKey)
lRetVal = QueryValEx(hKey, "username", vValue)
LoginName = vValue 'vValue is whatever is at the registry setting
lRetVal2 = RegOpenKeyEx(HKEY_Local_Machine, "network\uid", 0, KEY_ALL_ACCESS, hKey)
lRetVal2 = QueryValEx(hKey, "userid", vValue)
Userid = vValue2 'vValue is whatever is at the registry setting
RegCloseKey(hKey)
Private Sub cmdExit_Click()
End
End Sub
Private Sub Form_Load()
Dim lRetValue as Long 'result of the api functions
Dim hKey as Long ' handle of the opened key
Dim vValue as vatiant 'Setting of queried value
lRetVal = RegOpenKeyEx(HKEY_Local_Machine, "network\logon", 0, KEY_ALL_ACCESS, hKey)
lRetVal = QueryValEx(hKey, "username", vValue)
LoginName = vValue 'vValue is whatever is at the registry setting
lRetVal2 = RegOpenKeyEx(HKEY_Local_Machine, "network\uid", 0, KEY_ALL_ACCESS, hKey)
lRetVal2 = QueryValEx(hKey, "userid", vValue)
Userid = vValue2 'vValue is whatever is at the registry setting
RegCloseKey(hKey)
Label1.caption = "Your UserName is; " & loginName & "" _
+ Char$(13) + "Welcome " & LoginName & "" _
+ Char$(13) + "Date " & Date & "" _
+ Char$(13) + "Time " & Time & ""
MsgBox "" & F_GetUSerName & ""
Private Function F_GetUserName() as String
Dim strUser as String
strUser = Space(150)
If GetUserName(strUser, 150) = o then
F_GetUserName = ""
Exit Function
End if
'Take out the null value
strUser = mid(Trim(strUser), 1, Len(Trim(strUser))-1)
F_GetUserName = strUser
End Function
hope this works for you. Good Luck
John
-
Apr 24th, 2000, 06:15 AM
#3
Thread Starter
Addicted Member
-
Apr 27th, 2000, 02:44 AM
#4
Addicted Member
Oh my god! You don't need to do all that. Just use the GetUserName API!
Code:
Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long
[Edited by SonGouki on 04-27-2000 at 03:45 PM]
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
|