I created a Windows service and would like to send it a control+B or control+C control value. I know I can use sc control, but I was 开发者_如何学Gowondering if there was a location that contained all possible values I can send. There is a sc stop method, but I'm looking to send it a control character.
The "gracefulness" of a service shutdown all depends on how your service responds to the request. If you're writing the service, then you have full control over how your service responds when the SCM sends a "stop" request. After receiving the request, you have a limited amount of time (Windows decides how much) to stop your service and respond to the control request. If you fail to respond in a timely manner, Windows may terminate your service process ungracefully.
A console application can respond to a Ctrl+C request using the SetConsoleCtrlHandler()
function. However, service processes are not run inside a console window, so this handler is completely unapplicable to services.
精彩评论