Can I send a ctrl-C (SIGINT) to an application on Windows?

前端 未结 17 2824
甜味超标
甜味超标 2020-11-22 09:15

I have (in the past) written cross-platform (Windows/Unix) applications which, when started from the command line, handled a user-typed Ctrl-C combinat

17条回答
  •  甜味超标
    2020-11-22 09:48

    Edit:

    For a GUI App, the "normal" way to handle this in Windows development would be to send a WM_CLOSE message to the process's main window.

    For a console app, you need to use SetConsoleCtrlHandler to add a CTRL_C_EVENT.

    If the application doesn't honor that, you could call TerminateProcess.

提交回复
热议问题