#include
#include
#include
bool printAllProcess(std::map
{
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;
}
手机扫一扫
移动阅读更方便
你可能感兴趣的文章