編輯2:對於那些認爲這是重複的人,沒有這不是。這是在不同的背景下,知道如果一個進程正在運行,我不知道我需要轉換,直到在這裏'馬丁'給我的答案:https://stackoverflow.com/a/12637971/4908011C++:如何檢查一個確定的過程是否正在運行
我在Windows 7中使用Visual Studio 2013 Deluxe。我似乎無法找到任何方法來使兼容的x32控制檯應用程序找到一個進程。
我需要知道某個進程是否正在運行,例如, RobloxPlayerBeta.exe
。
我不斷收到錯誤:
WCHAR* incompatible with const char*
在 'STRCMP(procEntry.szExeFile,名)'
我使用的代碼:
bool ProcessRunning(const char* name)
{
HANDLE SnapShot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (SnapShot == INVALID_HANDLE_VALUE)
return false;
PROCESSENTRY32 procEntry;
procEntry.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(SnapShot, &procEntry))
return false;
do
{
if (strcmp(procEntry.szExeFile, name) == 0)
return true;
} while (Process32Next(SnapShot, &procEntry));
return false;
}
向我們展示一些代碼,否則我們無法幫助您。你如何枚舉正在運行的進程? – Nidhoegger
你能發表一些代碼嗎? – zmbq
增加了一些代碼 – realmaster42