Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Wait for Service to Start/Stop

I am using the service controller in C++ to manage a windows service.

I can use the StartService( ) and ControlService( ) functions to start and stop the service.

However, is there a standard way to wait for the service to actually start and stop?

I could obviously loop calling QueryServiceStatusEx( ) and wait until the status is Running or Stopped respectively.

Is there a neater way of achieving the same?

Thanks.

like image 832
Nick Avatar asked Nov 25 '25 23:11

Nick


1 Answers

Afaik Service start and stop create windows event log events. Maybe you could install a handler for those and wait for the event from your application. If your application is also a service mark it as depending on the 3rd party service then you should not have to wait on it.

like image 197
RedX Avatar answered Nov 27 '25 13:11

RedX



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!