GenerateConsoleCtrlEvent
The GenerateConsoleCtrlEvent
function sends a specified signal to a console process group that shares the
console associated with the calling process.
BOOL GenerateConsoleCtrlEvent(
DWORD dwCtrlEvent, |
// signal to
generate |
DWORD dwProcessGroupId |
// process group to
get signal |
); |
|
Parameters
dwCtrlEvent
Specifies the
type of signal to generate. One of the following values is specified:
Value |
Meaning |
CTRL_C_EVENT |
Generates a
CTRL+C signal. |
CTRL_BREAK_EVENT |
Generates a
CTRL+BREAK signal. |
dwProcessGroupId
Specifies the
identifier of the process group that receives the signal. A process group is
created when the CREATE_NEW_PROCESS_GROUP flag is specified in a call to the CreateProcess
If this
parameter is zero, the signal is generated in all processes that share the
console of the calling process.
Return Values
If the
function succeeds, the return value is nonzero.
If the
function fails, the return value is zero. To get extended error information,
call GetLastError
Remarks
GenerateConsoleCtrlEvent causes the control handler functions of processes in
the target group to be called. All console processes have a default handler
function that calls the ExitProcess
SetConsoleCtrlHandler can also enable an inheritable attribute that causes
the calling process to ignore CTRL+C signals. If GenerateConsoleCtrlEvent sends a CTRL+C signal to
a process for which this attribute is enabled, the handler functions for that
process are not called. CTRL+BREAK signals always cause the handler functions to be
called.
See Also