bool CheckProcess(wstring wstrExeName) { bool bHasProcess = false; unsigned long aProcesses[1024], cbNeeded, cProcesses; if(EnumProcesses(aProcesses, sizeof(aProcesses), &cbNeeded)) { cProcesses = cbNeeded / sizeof(unsigned long); for(unsigned int i = 0; i < cProcesses; i++) { if(aProcesses[i] == 0) continue; HANDLE hProcess = OpenProcess(PROCESS_QUERY_INFORMATION | PROCESS_VM_READ, 0, aProcesses[i]); wchar_t buffer[50]; GetModuleBaseNameW(hProcess, 0, buffer, 50); CloseHandle(hProcess); if(wstrExeName == wstring(buffer)) { bHasProcess = true; break; } } } return bHasProcess; }
沒有留言:
張貼留言