Getting the current logged in Windows user name when running as an NT service
Posted on 2003-11-04
I have a service (written in Visual Basic), running under Windows NT/2K/XP/2003. I need to get the name of the currently logged in user, but most Windows APIs I have found return the username of the *calling thread*, which when run as a system, is always "SYSTEM".
I have tried these APIs so far:
Unfortunately, all of the above return the username "SYSTEM". Any suggestions?
This code needs to run on Windows NT, 2000, XP and 2003.