Sending Ctrl-C to console processes

Sending Ctrl-C to console processes

Post by Klaus Brende » Tue, 21 Nov 2000 04:00:00



Hello,
I've written a service which is programatically installed on a remote
computer. The service connects to the launcjing app thru named pipes,
launches itself a cmd process and redirects its stdin/stdout via the pipes
(it's a primitive rcmd).
How can I send Ctrl-C signals to processes started by that remote
cmd-process?
 
 
 

Sending Ctrl-C to console processes

Post by Felix Kasza [MVP » Tue, 21 Nov 2000 04:00:00


Klaus,

 > How can I send Ctrl-C signals to processes started
 > by that remote cmd-process?

If they are in your console group (which means more or less that they
share your console), you can use GenerateConsoleCtrlEvent(). If they are
not, the only fix is to inject code and create a thread to execute it. A
simple example for injecting code and creating a thread is at
http://www.veryComputer.com/, despite
all the warnings, it is still less intrusive than a hook DLL.

--

Cheers,
Felix.

If you post a reply, kindly refrain from emailing it, too.
Please consider migrating to microsoft.public.platformsdk.*
where the MS folks plan on* around. See you there!

 
 
 

Sending Ctrl-C to console processes

Post by Klaus Brende » Wed, 22 Nov 2000 04:00:00


Well, Felix, I know the example on your website but didn't find the nerve to
try it till now.
I'll try it, eventually, hope I'm able to take use of it :-)

Thanks!



Quote:

> Klaus,

>  > How can I send Ctrl-C signals to processes started
>  > by that remote cmd-process?

> If they are in your console group (which means more or less that they
> share your console), you can use GenerateConsoleCtrlEvent(). If they are
> not, the only fix is to inject code and create a thread to execute it. A
> simple example for injecting code and creating a thread is at
> http://www.veryComputer.com/, despite
> all the warnings, it is still less intrusive than a hook DLL.

> --

> Cheers,
> Felix.

> If you post a reply, kindly refrain from emailing it, too.
> Please consider migrating to microsoft.public.platformsdk.*
> where the MS folks plan on* around. See you there!