user name in system service
C / C++ / MFC
2
Posts
2
Posters
0
Views
1
Watching
-
Hi, I am developing a service which will install on system level (not on user level). I need the name of current user logged in. Please suggest to get it.
There may be multiple users logged in. So you have to enumerate the logon sessions. See this old article: Enumerating Logon Sessions[^]. If the above methods does not work with recent Windows versions, you can use the WTSEnumerateSessions function (Windows)[^] as shown in this SO thread: c++ - How to get the active user when multiple users are logged on in Windows? - Stack Overflow[^].