• windows 枚举所有进程 WtsApi32 windows终端服务


     1 #include <WtsApi32.h>
     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 失败
    ");
    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 失败
    ");
    19         return;
    20     }
    21     //枚举所有进程的信息
    22     for (DWORD i = 0; i < dwCount; ++i) {
    23         printf("PID:%d	名称:%s
    ", pProcessInfo[i].ProcessId, pProcessInfo[i].pProcessName);
    24     }
    25     //内存释放
    26     WTSFreeMemory(pProcessInfo);
    27     //关闭服务
    28     //WTSCloseServer(hWtsServer);
    29 }

  • 相关阅读:
    JMeter和JMeterPlugin 下载安装
    Beanshell语法
    逻辑控制器
    常用配置元件
    jmeter结构体系
    正则表达式提取器
    ab 测试工具
    spring cloud_docker
    jmeter+maven
    TFS
  • 原文地址:https://www.cnblogs.com/xuqiulin/p/11992723.html
Copyright © 2020-2023  润新知