void MyFrame::ProcChecker(bool showmessage=false){
HANDLE hSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS,0);
PROCESSENTRY32 *processInfo = new PROCESSENTRY32;
processInfo->dwSize = sizeof(PROCESSENTRY32);
int index = 0;
string procList = "";
while(Process32Next(hSnapShot,processInfo) != false){
HANDLE modSnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPALL, processInfo->th32ProcessID);
MODULEENTRY32 *moduleInfo = new MODULEENTRY32;
moduleInfo->dwSize = sizeof(MODULEENTRY32);
index++;
stringstream indexstr;
indexstr << index;
Module32First(modSnapShot,moduleInfo);
procList = procList + indexstr.str() + ": " + wxString((string)processInfo->szExeFile) + "[" + wxString((string)moduleInfo->szExePath) + "]" + "\r\n";
}
if(showmessage){
MessageBox(NULL,procList.c_str(),"Processes",false);
}
}
我刚刚开始学习C++,所以我知道我目前的代码可能很糟糕:P