N
no one
Hi,
How do I kill a process in xp? It is really anoying. I have the code. I
suspect that I don't have permission to do it.
What is wrong with it?
HANDLE hProcess;
PROCESSENTRY32 pe32;
CString cstrProcess;
CString app;
BOOL bResult;
cstrProcess=process;
hProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcess == INVALID_HANDLE_VALUE)
{
return (FALSE);
}
pe32.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hProcess, &pe32))
{
CloseHandle(hProcess);
return (FALSE);
}
do
{
app=pe32.szExeFile;
if(cstrProcess==app)
{
// kill app if name matches
if(WaitForSingleObject(hProcess, 5000)
!=WAIT_OBJECT_0)
bResult = TerminateProcess(hProcess,0);
else
bResult = TRUE;
}
} while (Process32Next(hProcess, &pe32));
CloseHandle(hProcess);
return (TRUE);
How do I kill a process in xp? It is really anoying. I have the code. I
suspect that I don't have permission to do it.
What is wrong with it?
HANDLE hProcess;
PROCESSENTRY32 pe32;
CString cstrProcess;
CString app;
BOOL bResult;
cstrProcess=process;
hProcess = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
if (hProcess == INVALID_HANDLE_VALUE)
{
return (FALSE);
}
pe32.dwSize = sizeof(PROCESSENTRY32);
if (!Process32First(hProcess, &pe32))
{
CloseHandle(hProcess);
return (FALSE);
}
do
{
app=pe32.szExeFile;
if(cstrProcess==app)
{
// kill app if name matches
if(WaitForSingleObject(hProcess, 5000)
!=WAIT_OBJECT_0)
bResult = TerminateProcess(hProcess,0);
else
bResult = TRUE;
}
} while (Process32Next(hProcess, &pe32));
CloseHandle(hProcess);
return (TRUE);