Jump to content
AllanF

In my Service I want to to receive notification when the system is suspended or resumed

Recommended Posts

In my Service I want to to receive notification when the system is suspended or resumed (Hibernate/Sleep) so that I can Close Active Sockets connections.

Similar questions have got the answer 'the service must use a HandlerEx() callback via RegisterServiceCtrlHandlerEx()' but I have not been able to use it in Delphi.

Need more assistance please.

Share this post


Link to post

HandlexEx is supported by the DDService replacement for the Delphi version, written by Arno Garrels. 

 

You can also intercept WMPowerBroadcast messages which is sent at various stages before and after suspend and works fine in a service.  I have a THardwareEvents component I've never got around to releasing due to lack of documentation.

 

Angus

 

 

 

Share this post


Link to post

I have already tried the WM_POWERBROADCAST for GUID_MONITOR_POWER_ON with this I get notified even if display is begin turned off.

Share this post


Link to post

Don't think monitor power off will really help you, you need to check PowerEvents like PBT_APMQUERYSUSPEND and PBT_APMRESUMESUSPEND.  I'll email my unit that does all this.

 

Angus

 

  • Like 1

Share this post


Link to post

Yes, I've been using SvCom for 15 years, but it is commercial software.  DDService actually patches your local copy of TService, while SvCom borrowed it. 

 

Angus

 

Share this post


Link to post

>> I'll email my unit that does all this.

 

I looked at all the options suggested by Angus and Remy. Then I implemented the emailed Pas files and tested it with all possible options I could manage. Was most simple to include in my program and works perfectly fine. Very grateful to both for pulling me out of this one too. 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×