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
);
Value | Meaning |
---|---|
CTRL_C_EVENT | Generates a ctrl+c signal. |
CTRL_BREAK_EVENT | Generates a ctrl+break signal. |
If this parameter is zero, the signal is generated in all processes that share the console of the calling process.
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.
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 function. A console process can use the SetConsoleCtrlHandler function to install or remove other handler functions.
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.
Windows NT: Requires version 3.1 or later.
Windows: Requires Windows 95 or later.
Windows CE: Unsupported.
Header: Declared in wincon.h.
Import Library: Use kernel32.lib.
Consoles and Character-Mode Support Overview, Console Functions, CreateProcess, ExitProcess, SetConsoleCtrlHandler