函数原型:
BOOL WTSEnumerateSessions( HANDLE hServer,
DWORD Reserved,
DWORD Version,
PWTS_SESSION_INFO* ppSessionInfo,
DWORD* pCount
);
作用:对当前系统的session信息进行枚举。
参数说明:
hServer:指定要对终端断服务枚举的句柄,本机可以的话可以为WTS_CURRENT_SERVER_HANDLE, 或者NULL
Reserved:系统保留位,必须为0
Version:指定枚举请求的版本,必须为1
ppSessionInfo:一个WTS_SESSION_INFO结构
可以看一下该结构的定义:
typedef struct _WTS_SESSION_INFO
{
DWORD SessionId;
LPTSTR pWinStationName;
WTS_CONNECTSTATE_CLASS State;
} WTS_SESSION_INFO, * PWTS_SESSION_INFO; 该结构中包含绘画ID, Windows空间站名,session的状态,此状态为枚举值。再次看下一结构
typedef enum _WTS_CONNECTSTATE_CLASS
{
WTSActive, // User logged on to WinStation
WTSConnected, // WinStation connected to client
WTSConnectQuery, // In the process of connecting to client
WTSShadow, // Shadowing another WinStation
WTSDisconnected, // WinStation logged on without client
WTSIdle, // Waiting for client to connect
WTSListen, // WinStation is listening for connection
WTSReset, // WinStation is being reset
WTSDown, // WinStation is down due to error
WTSInit, // WinStation in initialization
} WTS_CONNECTSTATE_CLASS; pCount:返回Session的数量,为输出参数 举例说明:
   void main()

   {

        PWTS_SESSION_INFO psi;
DWORD dwCount; BOOL bRet = WTSEnumerateSessions(WTS_CURRENT_SERVER_HANDLE, 0, 1, &psi, &dwCount); if (!bRet)
return 0;
wstring strName;
for (unsigned int i = 0; i < dwCount; i ++)
{
printf("%s \t", psi[i].pWinStationName);
printf("%d \t", psi[i].SessionId);
printf("%d \n", psi[i].State);
}
WTSFreeMemory(psi); }

最新文章

  1. Laravel [1045] 解决方法 Access denied for user &#39;homestead&#39;@&#39;localhost&#39;
  2. Spring的DI(Ioc) - 注入集合类型
  3. BZOJ 1106 立方体大作战
  4. ubuntu下virtualbox使用u盘
  5. 自定义H5页面规范
  6. prepareStatement的用法和解释
  7. 【IIS小技巧】将IIS Express改成可以通过ip地址访问
  8. C# 异步和委托学习
  9. ‘Microsoft.Jet.OLEDB.4.0’ provider is not registered
  10. C++模板:欧拉函数
  11. nRF Toolbox 1.2 使用AKII的实现,而Becon始终不好使
  12. Delphi @ # $ 特殊字符含义
  13. js中Object.__proto__===Function.prototype
  14. Spring整合Hibernate(转)
  15. FastReport报表设计
  16. 使用 &quot;java -jar&quot;命令启动jar包时报不支持的jdk版本异常
  17. windows服务的默认启动类型和登录帐户
  18. 20145211黄志远 《网络对抗》Exp7 网络欺诈技术防范
  19. 【linux】linux的数据流重定向
  20. POJ--3461

热门文章

  1. leetcode-8-字符串转换整数(atoi)
  2. Vim: 强大的g
  3. p分位数的原理及计算
  4. day15 python-03 列表,元组,字典
  5. jq 图片上传前预览
  6. LeetCode 8.字符串转换整数 (atoi)(Python3)
  7. ansible 安装及基本使用
  8. [转]Entity Framework 的实体关系
  9. [转]WPF——Thumb
  10. [JZOJ5977] 【清华2019冬令营模拟12.15】堆