Hi ...
Does anyone know how to get User ID
from NT/Novell using API ?
Pls let me know.
Thank you
Keiko
Printable View
Hi ...
Does anyone know how to get User ID
from NT/Novell using API ?
Pls let me know.
Thank you
Keiko
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
Thanks
Oh my god! You don't need to do all that. Just use the GetUserName API!
[Edited by SonGouki on 04-27-2000 at 03:45 PM]Code:Private Declare Function GetUserName Lib "advapi32.dll" Alias "GetUserNameA" (ByVal lpBuffer As String, nSize As Long) As Long