CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1

    Is it Possible to Handle Shutdown or Restart Windows?

    Hello Gurus,
    I have a Strange Problem. I am updating a counter on the disk by doing a Write to the Disk from a Windows Service in VC++ and i need to handle the case when the user restarts or shuts down the system. This is because sometimes shutdown screws up the counter value. So if i am able to handle shutdown or restart windows from Service i can do the necessary clean up in the Service and then exit the service and let the shutdown or restart to proceed.
    Is it possible to do that?
    Thank you
    Kandukondein
    C++ is divine.

  2. #2
    Join Date
    Feb 2004
    Location
    where Eurasian, Pacific and Philippine tectonic plates meet
    Posts
    229

    Re: Is it Possible to Handle Shutdown or Restart Windows?

    I guess if it is a service you don't have any window (you don't get the WM_QUERYENDSESSION message if you don't process them "manually"). However this article may help you in the case of a service.
    For the Restart since it is a service you know when it is starting...
    "Such ingratitude after all the times I saved your life." (imdb quotes)
    A bit of history.

  3. #3
    Join Date
    May 2005
    Posts
    4,954

    Re: Is it Possible to Handle Shutdown or Restart Windows?

    you can also read this Thread

    Cheers
    If a post helped you dont forget to "Rate This Post"

    My Article: Capturing Windows Regardless of Their Z-Order

    Cheers

  4. #4
    Join Date
    Feb 2003
    Location
    Iasi - Romania
    Posts
    8,244

    Re: Is it Possible to Handle Shutdown or Restart Windows?

    If I have correctly read, the OP refers to a service.
    Because I'm not so experimented in this domain I just can suggest to search MSDN for SERVICE_CONTROL_SHUTDOWN.
    One link may be THIS.
    Ovidiu
    "When in Rome, do as Romans do."
    My latest articles: https://codexpertro.wordpress.com/

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured