I got this work on Windows Embedded Compact 7. Final events Ctrl + C and "windows closed."
- Create a Win32 event.
- Pass this DeviceIoControl () event with IOCTL_CONSOLE_SETCONTROLCEVENT and pass a console handle (e.g. _fileno (stdout)). This event will be signaled when you enter Ctrl + C or close the console window.
- Create a thread that waits for the Win32 event to signal, and when it becomes such, it calls your handler Ctrl + C or performs your cleanup and probably exits the program.
Note that IOCTL_CONSOLE_SETCONTROLCHANDLER is deprecated, and DeviceIoControl () fails if it is given this IOCTL code.
source share