We have a small windows application that we need to run as a system process. However, somewhere in the application code, we need to get the login ID of the currently logged on user.

If we use the GetUserName function, it will return SYSTEM since this is running as a system application. So, is there a way for an application running as a system process to get the login ID / username of the currently logged-on user?