How to gracefully terminate a process?

后端 未结 6 1697
深忆病人
深忆病人 2020-11-30 03:14

I want to terminate a number of processes, but I want to give each process the chance to save its data, ask the user about saving a file and even ignore the close request.

6条回答
  •  一整个雨季
    2020-11-30 03:38

    You can use taskkill /im your_program.exe to send a termination signal to the application. It will trigger a WM_CLOSE to windows message queue. You can use Either https://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx or

    https://docs.microsoft.com/en-us/windows/desktop/api/winuser/nf-winuser-getmessage

    to process the message.

    Please refer a similar answer Win32 API analog of sending/catching SIGTERM

提交回复
热议问题