WinNT service and system shutdown
-
Hi all, I have a servive that laucnh a third party program. When the system shuts down, I try to use my service control handler to process the SERVICE_CONTROL_SHUTDOWN request from the system for terminating the launched program (by using TerminateProcess func), but it doesn't work and the system pop up some message that says "OleMainTreadWndName cannot respond to End Task Request". It seems the third party program gets hang! I then try to use SetConsoleCtrlHandler() to setup a handler routine to catch the CTRL_SHUTDOWN_EVENT and terminate the process a bit ealier than the SERVICE_CONTROL_SHUTDOWN request, but it doesn't work either. Now I try to add up the CTRL_LOGOFF_EVENT and terminate the process at this event, then there is no error message shows up. It seems to me that I need to terminate the process ealier, at the time my service receive the CTRL_LOGOFF_EVENT. But the problem is, if user just log off, but not shut down the system, the process gets terminated! Anyone know some way so that at the time I receive the CTRL_LOGOFF_EVENT, I also know whether the system is going to shut down or not? Thank you for your help, Rocky Lee :confused:
-
Hi all, I have a servive that laucnh a third party program. When the system shuts down, I try to use my service control handler to process the SERVICE_CONTROL_SHUTDOWN request from the system for terminating the launched program (by using TerminateProcess func), but it doesn't work and the system pop up some message that says "OleMainTreadWndName cannot respond to End Task Request". It seems the third party program gets hang! I then try to use SetConsoleCtrlHandler() to setup a handler routine to catch the CTRL_SHUTDOWN_EVENT and terminate the process a bit ealier than the SERVICE_CONTROL_SHUTDOWN request, but it doesn't work either. Now I try to add up the CTRL_LOGOFF_EVENT and terminate the process at this event, then there is no error message shows up. It seems to me that I need to terminate the process ealier, at the time my service receive the CTRL_LOGOFF_EVENT. But the problem is, if user just log off, but not shut down the system, the process gets terminated! Anyone know some way so that at the time I receive the CTRL_LOGOFF_EVENT, I also know whether the system is going to shut down or not? Thank you for your help, Rocky Lee :confused: