1

I have a C++ Windows service which starts a TCP server when booted. The problem is that when the user logs on/off the service no longer responses to client requests, also when returns from hibernation. So I need to get notified about the power modes so that I suspend/resume the server the proper way.

I tried ServiceBase.OnPowerEvent() but visual studio says it is undefined. is this method available only for C#? is there a counterpart in C++?

It is worth mentioned that the service template I used have downloaded it from an online tutorial, not the default template that comes with VS.

Malek
  • 115
  • 1
  • 9
  • See the C++ answer to http://stackoverflow.com/questions/228288/how-can-i-know-when-windows-is-going-into-out-of-sleep-or-hibernate-mode/31033210#31033210 – Richard Chambers May 02 '16 at 14:46

1 Answers1

0

ServiceBase.OnPowerEvent is for .Net services based on ServiceBase. It is a wrapper of SERVICE_CONTROL_POWEREVENT.Services are also notified of log on and log off events via SERVICE_CONTROL_SESSIONCHANGE.

For a list of notification code, check HandlerEx callback function

Sheng Jiang 蒋晟
  • 15,125
  • 2
  • 28
  • 46