
How to terminate a process
Hi,
Could someone tell me how to terminate a process? Below is a snippet of the
code. I have traced through it. The call to CreateProcess() is successful
but the call to TerminateProcess() failed. I need to create the process in
DEBUG_PROCESS mode because I'm trying to capture debug events. Thanks.
memset(&ProcInfo, 0x0, sizeof(ProcInfo));
BOOL bRet = CreateProcess(bstrAppName, L"", NULL, NULL, NULL,
DEBUG_PROCESS, NULL, NULL, NULL, &ProcInfo);
BOOL bSuccess = TerminateProcess(ProcInfo.hProcess, 1);
if(!bSuccess)
{
long lRet = GetLastError();
CloseHandle(ProcInfo.hProcess);
return E_FAIL;
}