windows 枚举所有进程 WtsApi32 windows终端服务
标签:turn 个数 lib bsp har span pid 释放 img
1 #include 2 #pragma comment(lib, "WtsApi32.lib")
3 void fun17(int argc, char *argv[]){
4 ////计算机名
5 //TCHAR szServerName[32] = TEXT("DESKTOP-45J0D6P");
6 ////把这台计算机当服务打开
7 //HANDLE hWtsServer = WTSOpenServer(szServerName);
8 //if (hWtsServer == INVALID_HANDLE_VALUE) {
9 // printf("WTSOpenServer 失败\n");
10 // return;
11 //}
12 //终端服务进程信息
13 PWTS_PROCESS_INFO pProcessInfo;
14 //进程个数
15 DWORD dwCount;
16 //if (!WTSEnumerateProcesses(hWtsServer, 0, 1, &pProcessInfo, &dwCount)) {
17 if (!WTSEnumerateProcesses(WTS_CURRENT_SERVER_HANDLE, 0, 1, &pProcessInfo, &dwCount)) {
18 printf("WTSEnumerateProcesses 失败\n");
19 return;
20 }
21 //枚举所有进程的信息
22 for (DWORD i = 0; i i) {
23 printf("PID:%d\t名称:%s\n", pProcessInfo[i].ProcessId, pProcessInfo[i].pProcessName);
24 }
25 //内存释放
26 WTSFreeMemory(pProcessInfo);
27 //关闭服务
28 //WTSCloseServer(hWtsServer);
29 }
windows 枚举所有进程 WtsApi32 windows终端服务
标签:turn 个数 lib bsp har span pid 释放 img
原文地址:https://www.cnblogs.com/xuqiulin/p/11992723.html
评论