• win10打印所有进程


    #include <map>
    #include <iostream>
    #include <string>
    
    #include <windows.h>
    #include <TlHelp32.h> // Never include win32 heads before window.h
    
    
    bool printAllProcess(std::map<std::wstring, int> &_mapProcess, bool is_print = true)
    {
    	PROCESSENTRY32 pe32;
    	pe32.dwSize = sizeof(pe32);
    
    	HANDLE hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
    	if (hProcessSnap == INVALID_HANDLE_VALUE) {
    		std::cout << "CreateToolhelp32Snapshot Error!" << std::endl;;
    		return false;
    	}
    
    	BOOL bResult = Process32First(hProcessSnap, &pe32);
    
    	int num(0);
    
    	while (bResult)
    	{
    		std::wstring name = pe32.szExeFile;
    		int id = pe32.th32ProcessID;
    		if (is_print)
    		{
    			std::cout << "[" << ++num << "]: " << "--ProcessID:" << id;
    			std::wcout << "--Process Name:" << name << std::endl;
    		}
    		_mapProcess.insert(std::pair<std::wstring, int>(name, id)); 
    		bResult = Process32Next(hProcessSnap, &pe32);
    	}
    
    	CloseHandle(hProcessSnap);
    	return true;
    }
    

      

  • 相关阅读:
    hdu 1087(LIS变形)
    poj 1088(记忆化搜索)
    hdu 1505(最大子矩阵)
    hdu 1506(好题+DP或者RMQ)
    poj 2593&&poj2479(最大两子段和)
    hdu 1003(最大子段和)
    hdu 2881(LIS变形)
    poj 1692(动态规划)
    CodeForces 626C Block Towers
    CodeForces 626B Cards
  • 原文地址:https://www.cnblogs.com/alexYuin/p/9697636.html
Copyright © 2020-2023  润新知