devxlogo

Get login information the easy way (without any API call)

Get login information the easy way (without any API call)

While you can use many different API function to get user and domain information, if you’re running under Windows NT or 2000 Server there is a shortest path, based on the fact that the operating system loads many piece of data into environment variables:

' this code works only under Windows NT and Windows 2000 ServerDebug.Print "Computer Name: " & Environ$("COMPUTERNAME")Debug.Print "Logon Server: " & Environ$("LOGONSERVER")Debug.Print "User Domain: " & Environ$("USERDOMAIN")Debug.Print "User Name: " & Environ$("USERNAME")

devx-admin

Share the Post: