如何从会话 ID 中查找用户名?
How to find user name from the session ID?
我有一个用户 win32 应用程序。它枚举了所有进程详细信息以及 ProcessId。我需要打印用户名和会话 ID。使用 ProcessIdToSessionId() 方法枚举 SessionID。我想打印相应 SessionID 的用户名。此应用程序专为 WindowsXP 设计,因此 API 应该支持 WindowsXP。如果有人知道解决方案,请分享。
DWORD dwSessionId,dwPid,dwErr;
char* Uname;
ProcessIdToSessionId(dwPid,&dwSessionId);
WTSQuerySessionInformation()
with the WTSInfoClass
parameter set to WTSUserName
:
A null-terminated string that contains the name of the user associated with the session.
我有一个用户 win32 应用程序。它枚举了所有进程详细信息以及 ProcessId。我需要打印用户名和会话 ID。使用 ProcessIdToSessionId() 方法枚举 SessionID。我想打印相应 SessionID 的用户名。此应用程序专为 WindowsXP 设计,因此 API 应该支持 WindowsXP。如果有人知道解决方案,请分享。
DWORD dwSessionId,dwPid,dwErr;
char* Uname;
ProcessIdToSessionId(dwPid,&dwSessionId);
WTSQuerySessionInformation()
with the WTSInfoClass
parameter set to WTSUserName
:
A null-terminated string that contains the name of the user associated with the session.