SpprtMechanic
asked on
Retrieving Domain of Logged in user
After countless searching I still can't find the answer.
The problem is this. I am writing a VB program that needs to know who the user is that is logged into windows. I can get the username just fine using the Windows API GetUserNameA, however I need the domain name of the account also. The GetUserNameA only returns the Username of the account. The domain is necessary part so the program can run properly since it will connect to a SQL database using Windows NT authentication.
Only requirement, can not use Windows Scripting Host, since the exe will be ran from a network directory I can not take the chance on whether or not the machine has WSH installed (or some other non common DLL).
Thanks.
The problem is this. I am writing a VB program that needs to know who the user is that is logged into windows. I can get the username just fine using the Windows API GetUserNameA, however I need the domain name of the account also. The GetUserNameA only returns the Username of the account. The domain is necessary part so the program can run properly since it will connect to a SQL database using Windows NT authentication.
Only requirement, can not use Windows Scripting Host, since the exe will be ran from a network directory I can not take the chance on whether or not the machine has WSH installed (or some other non common DLL).
Thanks.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
This will loop through the available variables and their values:
Private Sub Command1_Click()
For x = 1 To 80
MsgBox Environ(x)
Next x
End Sub
Private Sub Command1_Click()
For x = 1 To 80
MsgBox Environ(x)
Next x
End Sub
ASKER
Thanks.