Answer the question
In order to leave comments, you need to log in
Pass child process CTRL-C in C/C++?
STARTUPINFO cif;
ZeroMemory(&cif,sizeof(STARTUPINFO));
PROCESS_INFORMATION pi;
//AllocConsole();
CreateProcess("c:\\windows\\system32\\defrag.exe","foo D:",
NULL,NULL,TRUE,(CREATE_NEW_PROCESS_GROUP,CREATE_NEW_CONSOLE),NULL,NULL,&cif,&pi);
GenerateConsoleCtrlEvent (CTRL_C_EVENT, pi.dwProcessId);
Answer the question
In order to leave comments, you need to log in
a,b in C/C++ is calculated as b. You took two constants separated by commas into parentheses, after which they began to be perceived as a "comma" operation, the result of which is the second argument. Those. if you write a = (67, 23), then the value 23 will get into the variable a. In your case, only the CREATE_NEW_CONSOLE flag will be passed to the function, and, judging by MSDN, you need both to create a new process group. Connect the flags as it was originally necessary - through the logical or operation, i.e. "|" - and everything should work. Instead of what's in parentheses, it would be:
CREATE_NEW_PROCESS_GROUP | CREATE_NEW_CONSOLE
Edit: No, CTRL-C doesn't seem to be supported for process groups, try CTRL-BREAK. And these flags are mutually exclusive, judging by the docks. CREATE_NEW_PROCESS_GROUP: This flag is ignored if specified with CREATE_NEW_CONSOLE.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question