Jump to content


Check out our Community Blogs

Register and join over 40,000 other developers!


Recent Status Updates

View All Updates

Photo
- - - - -

Capture Windows Exit

pascal

  • Please log in to reply
1 reply to this topic

#1 mnij

mnij

    CC Lurker

  • Just Joined
  • Pip
  • 1 posts
  • Programming Language:Delphi/Object Pascal, Pascal
  • Learning:Delphi/Object Pascal, Pascal

Posted 16 August 2012 - 03:43 AM

Hi Everyone

I've written a small app in Free Pascal which runs silently on Windows as a GUI apptype with no output. When Windows shuts down or logs off the program closes but I need to put in some exit code to clean up a connection the app makes elsewhere.

After researching around there seem to be lots of signals sent out by Windows depending on the type of termination, can anyone point me in the right direction?

TIA
  • 0

#2 Luthfi

Luthfi

    CC Leader

  • Expert Member
  • PipPipPipPipPipPipPip
  • 1320 posts
  • Programming Language:PHP, Delphi/Object Pascal, Pascal, Transact-SQL
  • Learning:C, Java, PHP

Posted 22 August 2012 - 07:36 PM

You can do your clean up safely by handling either one of these messages:


Basically, WM_QUERYENDSESSION is used by windows to notify applications that the user wants to log off or to shutdown. Applications might prevent the process by returning FALSE to upon receiving this message.

WM_ENDSESSION is sent by windows after none of the applications that received WM_QUERYENDSESSION returned FALSE.
  • 0





Also tagged with one or more of these keywords: pascal

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download