Please help me to get this faster because right now it makes a decent CPU usage.
bool CMemory::IsProcessRunning(DWORD dwPID, char* szProcessName = NULL)
{
HANDLE hPID = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
PROCESSENTRY32 pEntry;
pEntry.dwSize = sizeof(pEntry);
if (Process32First(hPID, &pEntry))
{
do
{
if (pEntry.th32ProcessID == dwPID && (!strcmp(pEntry.szExeFile, szProcessName) || szProcessName == NULL))
{
CloseHandle(hPID);
return TRUE;
}
} while (Process32Next(hPID, &pEntry));
}
CloseHandle(hPID);
return FALSE;
}
Any answer will be appreciated. Thanks.
By the way, I really like to use built-in WinAPI. Don't suggest any libraries please.
Aucun commentaire:
Enregistrer un commentaire