I just went through your code
while(Res)
{
if(strProcess.CompareNoCase(pe32.szExeFile)==0)
{
DWORD dwExitCode = pe32.th32ProcessID;
HANDLE hProcess=::OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe32.th32ProcessID);
::GetExitCodeProcess(hProcess,&dwExitCode);
Res = ::TerminateProcess(hProcess,dwExitCode);
}
Res=Process32Next(hProcessSnap,&pe32);
::CloseHandle(hProcessSnap);
}DWORD dwExitCode = pe32.th32ProcessID;
HANDLE hProcess=::OpenProcess(PROCESS_ALL_ACCESS,FALSE,pe32.th32ProcessID);
::GetExitCodeProcess(hProcess,&dwExitCode);
Res = ::TerminateProcess(hProcess,dwExitCode);
i have some review comments!
- when terminating the process, atleast check is it active or not, hint: use waitforsingleobject
- why are you getting GetExitCodeProcess before actually calling terminateprocess api
- can't you provide simple close down medium in your install.exe instead utilizing dangerous terminateprocess api. hint: window message WM_QUIT!
rest will go through again and will update it!