Reputation: 55
I am not able to close the process nb.exe. I need to close this process but it is not getting closed. During closing I also need to ensure that all the dll are unloaded related to this process. Below is my code.
bool ProcessExit(void) { PROCESSENTRY32 entry; entry.dwSize = sizeof(PROCESSENTRY32);
HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, NULL);
if (Process32First(snapshot, &entry) == TRUE)
{
while (Process32Next(snapshot, &entry) == TRUE)
{
if (wcsicmp(entry.szExeFile, L"nb.exe") == 0)
{
HANDLE hProcess = OpenProcess(PROCESS_ALL_ACCESS, FALSE, entry.th32ProcessID);
ExitProcess(entry.th32ProcessID);
CloseHandle(hProcess);
}
}
}
CloseHandle(snapshot);
return 1;
}
Please let me know if you have any inputs.
Upvotes: 0
Views: 98
Reputation: 5642
I think you are mistaken as to what ExitProcess(value) does. You are not doing anything to the process running nb.exe, but are exiting the current process with nb's process ID as the exit code.
Upvotes: 1