Win32 API analog of sending/catching SIGTERM

人走茶凉 提交于 2019-11-27 15:31:30
Christopher

You get a WM_QUIT message on your first created thread.

When you don't handle that, your process is forcibly shutdown.

So just implement a message queue in your first thread, which looks for the WM_QUIT message

MSDNs Unix Code Migration Guide has a chapter about Win32 code conversion and signal handling.
Although Microsoft has decided to archive this brilliant guide, it is very useful.

Three methods are described:
Native signals
Event objects
Messages

May be Windows Power Management from MSDN would be helpful. But it deals with system events rather than per process.

For a process, you would be able to detect termination with WM_CLOSE. You would need to handle windows messages. If it's a console application you would need to install a control handler; take a look at SetConsoleCtrlHandler on MSDN

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!