Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. System Admin
  4. WinNT service and system shutdown

WinNT service and system shutdown

Scheduled Pinned Locked Moved System Admin
helpquestionworkspace
2 Posts 2 Posters 3 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Le Phuc Nguyen Tuan
    wrote on last edited by
    #1

    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:

    K 1 Reply Last reply
    0
    • L Le Phuc Nguyen Tuan

      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:

      K Offline
      K Offline
      Kyui Oh
      wrote on last edited by
      #2

      What kind of a third party program is it? I haven't tried this, how about posting a message to the third party program using "PostMessage(...)" with the WM_QUIT parameter when you get the shutdown message from the SCM?

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups