首页 > Windows开发 > 详细

Windows API 23 篇 WTSQuerySessionInformation

时间:2018-10-08 17:41:15      阅读:208      评论:0      收藏:0      [点我收藏+]

函数原型:
BOOL
WINAPI
WTSQuerySessionInformationW(
                                                      IN HANDLE hServer,
                                                      IN DWORD SessionId,
                                                      IN WTS_INFO_CLASS WTSInfoClass,
                                                      __deref_out_bcount(*pBytesReturned) LPWSTR * ppBuffer,
                                                      __out DWORD * pBytesReturned
                                                      );
说明:
hServer: WTS_CURRENT_SERVER_HANDLE
SessionId:会话ID,可以从WTSEnumerateProcesses或者WTSEnumerateSessions 或WTSGetActiveConsoleSessionId
中得到,
WTSInfoClass:指定要查找的信息,该结构是一个枚举类型,可以看下面定义:
typedef enum _WTS_INFO_CLASS {
  WTSInitialProgram,
  WTSApplicationName,
 WTSWorkingDirectory,
 WTSOEMId,
 WTSSessionId,
 WTSUserName,
 WTSWinStationName,
 WTSDomainName,
 WTSConnectState,
 WTSClientBuildNumber,
 WTSClientName,
  WTSClientDirectory,
 WTSClientProductId,
 WTSClientHardwareId,
WTSClientAddress,
WTSClientDisplay,
WTSClientProtocolType
 } WTS_INFO_CLASS;

ppBuffer:输出指针
pBytesReturned:返回信息的长度

DWORD dwSessionId = WTSGetActiveConsoleSessionId();
		PVOID pstr = NULL;
		DWORD dwLen = 0;
		WTSQuerySessionInformationW(WTS_CURRENT_SERVER_HANDLE, dwSessionId, WTS_INFO_CLASS::WTSUserName, (LPWSTR*)&pstr, &dwLen);
	
		wstring strUserName = (PWCHAR)pstr;

 

Windows API 23 篇 WTSQuerySessionInformation

原文:https://www.cnblogs.com/priarieNew/p/9755664.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!