码迷,mamicode.com
首页 > Windows程序 > 详细

Windows API 23 篇 WTSQuerySessionInformation

时间:2018-10-08 18:04:18      阅读:1667      评论:0      收藏:0      [点我收藏+]

标签:roc   pst   add   http   stat   rate   word   query   ati   

函数原型:
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

标签:roc   pst   add   http   stat   rate   word   query   ati   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!