Interest ctrl+c problem

Hi everyone, I need to send ctrl+c command to another executable file, I mean I have program1.exe running in a DOS window, and I want to create a code to send ctrl+c to program1.exe.

Anyone??

If I understand your question correctly, you want let the user press Ctrl-C in a console application without having it terminate the program?

1
2
3
4
5
6
7
8
9
10
11
#include <windows.h>

// Change the console input mode to allow Ctrl-C as input
// You might also want to disable line-buffering and echoing too,
// but this example does not do that. Google "msdn setconsolemode"
// for more information.
DWORD mode;
HANDLE hstdin = GetStdHandle( STD_INPUT_HANDLE );
GetConsoleMode( hstdin, &mode );
mode &= ~(ENABLE_PROCESSED_INPUT);
SetConsoleMode( hstdin, mode );


Good luck.
Or you want to stimulate ctrl+c?
Hmm i don't know what you really want but heres is a good start
SendInput function/method
SendKey function/method
process.h or if you prefer MFC: Process Class
how to use it:
http://msdn.microsoft.com/

Jeff
Last edited on
closed account (L0M4jE8b)
It sounds like you just want to kill a process, try something like pskill.exe. It's a small freeware program that allows you to kill a program if you know it's pid in windows.
For process termination/management in windows I actually recommend sysintenals process explorer. It allows termination of processes, programs, individual threats, listing handles, etc. A very useful app. Also quite free.
Topic archived. No new replies allowed.