However, I am getting ERROR_INVALID_HANDLE returned
from GenerateConsoleCtrlEvent when I attempt to do this.
Any idea why?
When I run the program normally (not as a service) this
strategy works as expected.
I have tried toggling the "allow service to interact with
desktop" flag as well as having the service log in as
my user account and still get the same error.
Any help is appreciated.
Thanks.
-------------------==== Posted via Deja News ====-----------------------
http://www.dejanews.com/ Search, Read, Post to Usenet
> However, I am getting ERROR_INVALID_HANDLE returned
> from GenerateConsoleCtrlEvent when I attempt to do this.
> Any idea why?
No, sorry. I can only suggest an alternate strategy: Either use a
named event, or pass the handle to an inheritable one. The children
would basically poll the event or wait on it in a separate thread.
When it's time to die, your main process sets the event, and so on.
Cheers,
Felix.
----------
If you post a reply, kindly refrain from emailing it, too.
You are assuming that I have access to the source code for the child
processes, which I do not. So your proposed solution will not work for
me. I'm open to other suggestions.
>In theory, this will allow my service to later call
>GenerateConsoleCtrlEvent(CTRL_BREAK_EVENT,..)
>to kill the child process and all of its descendants.
GenerateConsoleCtrlEvent() fails whenever the calling process and the
specified process group don't share the same console. Perhaps your
service has no associated console, or perhaps you're specifying
CREATE_NEW_CONSOLE in the call to CreateProcess. Try using
FreeConsole and AllocConsole in your service before starting the new
process and see if that makes a difference.
Hope this helps,
Steven Doerfler
Lugaru Software, Ltd.