Process Snapshot error?
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
|
void KillProcess(string str)
{
HANDLE hProcessSnap;
HANDLE hProcess;
PROCESSENTRY32 pe32;
DWORD dwPriorityClass;
hProcessSnap = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if(hProcessSnap == INVALID_HANDLE_VALUE)
{
return;
}
pe32.dwSize = sizeof(PROCESSENTRY32);
if(!Process32First(hProcessSnap, &pe32));
{
printError("Process32First");
CloseHandle(hProcessSnap);
return;
}
do
{
char tmp[64];
wsprintf(tmp, "%s", pe32.szExeFile);
MessageBox(hWnd, tmp, NULL, NULL);
}
while(Process32Next( hProcessSnap, &pe32 ));
}
|
it stops on
1 2 3 4 5 6
|
if(!Process32First(hProcessSnap, &pe32));
{
printError("Process32First");
CloseHandle(hProcessSnap);
return;
}
|
however the error output is
WARNING: Process32First failed with error 0 (The operation completed successfully) |
I basically copy-pasted this code
http://msdn.microsoft.com/en-us/library/windows/desktop/ms686701(v=vs.85).aspx
edit: when I remove that check everything works fine ... is this intended? did I copy something wrong?
Last edited on
You have an extra ';' character on 'if' line, remove it.
ah lol, thanks!
Topic archived. No new replies allowed.