|
-
Jun 13th, 2000, 09:59 PM
#1
Thread Starter
Lively Member
I've got a serious problem... I'm trying to find the right way (or tool) to read the registry (WIN95/98, WINNT and WIN2000) at the following location: HKEY_LOCAL_MACHINE\Network\Logon and the variable would be username
or anything better.
It's easy to extract from WINNT since we can use the Environ$("OS") and also Environ$("USERNAME") to determine which OS were running and what is the Logged on user... How can I dot it in WIN 95/98???
Is there anyone out there with the proper answer...
I need to identify the user from within the application without having them to retype it.
-
Jun 13th, 2000, 10:09 PM
#2
Lively Member
Well, the way I do it is to use "GetUserNameW" in "advapi32.dll". However, we have NT throughout our organisation so see if you can find that library on your win95/98 machines and if so, reply and I'll post all the code.
Toot
Some cause happiness wherever they go; others, whenever they go.
-
Jun 13th, 2000, 10:15 PM
#3
Addicted Member
Paste this into a module:-
Code:
Private Declare Function GetUserName Lib "advapi32.dll" _
Alias "GetUserNameA" (ByVal lpBuffer As String, _
nSize As Long) As Long
Public Function UserName() As String
Dim llReturn As Long
Dim lsUserName As String
Dim lsBuffer As String
lsUserName = ""
lsBuffer = Space$(255)
llReturn = GetUserName(lsBuffer, 255)
If llReturn Then
lsUserName = Left$(lsBuffer, InStr(lsBuffer, Chr(0)) - 1)
End If
UserName = lsUserName
End Function
Then you just do stuff like Label1.caption = UserName
Visual Basic 6 Enterprise Edition + SP4
-
Jun 13th, 2000, 10:55 PM
#4
Lively Member
Couldn't have put it better myself!!
Some cause happiness wherever they go; others, whenever they go.
-
Jun 13th, 2000, 11:27 PM
#5
Thread Starter
Lively Member
Thank you
Thanks a bunch you guys...
Appreciate it a lot...
Sincerely yours,
Patrice Bourdages
IS Analyst
Quebec, Quebec, Canada
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
|