Closing hh.exe when my programs exits.
-
Hi, I have launch the hh.exe ( help viewer) via CreateProcess(). I am trying to close this window when my main program exits. How do I do that? Here's a snip of my code... bSuccess = CreateProcess ("C:\\WINDOWS\\HH.EXE"," NATURAL.CHM", NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &ppi ); helphnd = ppi.hProcess; CloseHandle ( ppi.hThread ); CloseHandle ( ppi.hProcess ); The code is written as part of defining a 'Help' menuitem. Quite new to the idea of process, copy this idea from FAQ in this website. If CloseHandle is executed right after CreateProcess, that means the process should have finish and return to the executing program, therefore closehandle would do the cleaning up? Now, I am executing something in the ::OnCloseDocument(), how do I check whether the help program is still running,so that I wouldn't be trying to close the program? :~
-
Hi, I have launch the hh.exe ( help viewer) via CreateProcess(). I am trying to close this window when my main program exits. How do I do that? Here's a snip of my code... bSuccess = CreateProcess ("C:\\WINDOWS\\HH.EXE"," NATURAL.CHM", NULL, NULL, TRUE, NORMAL_PRIORITY_CLASS, NULL, NULL, &si, &ppi ); helphnd = ppi.hProcess; CloseHandle ( ppi.hThread ); CloseHandle ( ppi.hProcess ); The code is written as part of defining a 'Help' menuitem. Quite new to the idea of process, copy this idea from FAQ in this website. If CloseHandle is executed right after CreateProcess, that means the process should have finish and return to the executing program, therefore closehandle would do the cleaning up? Now, I am executing something in the ::OnCloseDocument(), how do I check whether the help program is still running,so that I wouldn't be trying to close the program? :~
unsigned long status;
int rv = GetExitCodeProcess(ppi.hProcess, &status);Todd Smith
-
unsigned long status;
int rv = GetExitCodeProcess(ppi.hProcess, &status);Todd Smith
-
THanks for the reply. It's this function just checking whether the process is closed? How to close the process then?
First try to get a handle to the main window and then do a SendMessage with WM_CLOSE. If that doens't work then try TerminateProcess. See http://www.codetools.com/threads/asyncprocnotify.asp[^] Todd Smith