in reply to Re^3: Killing a process on Windows (Win32::Process question)
in thread Killing a process on Windows (Win32::Process question)
Apologies for displaying a foreign language on this site.static int getppid(void) { HANDLE hToolSnapshot; PROCESSENTRY32 Pe32 = {0}; BOOL bResult; DWORD PID; DWORD PPID = 0; PID = GetCurrentProcessId (); hToolSnapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0); if (hToolSnapshot == INVALID_HANDLE_VALUE) { return 0; } Pe32.dwSize = sizeof(PROCESSENTRY32); bResult = Process32First(hToolSnapshot, &Pe32); if (!bResult) return 0; while ( Process32Next(hToolSnapshot, &Pe32) ) { if (Pe32.th32ProcessID == PID) { PPID = Pe32.th32ParentProcessID; break; } } /* Expected */ if (GetLastError() == ERROR_NO_MORE_FILES) { SetLastError(ERROR_SUCCESS); } return PPID; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Killing a process on Windows (Win32::Process question)
by John M. Dlugosz (Monsignor) on May 15, 2009 at 17:48 UTC |