程式功能要求是這樣的: 捕獲到關機事件 -> 中斷關機 -> 執行程式備份資料庫檔案完畢 -> 繼續關機事件(要求關機模式不變)
目前使用 WindowProc(UINT message, WPARAM wParam, LPARAM lParam) 捕獲關機事件,似乎區分不了關機還是重啟,請高手指點。(如果能區分休眠和待機就更好了)
uj5u.com熱心網友回復:
if (m.Msg == WM_QUERYENDSESSION)You need to check the lParam value of the WM_QUERYENDSESSION message.
As the documentation indicates:
If the parameter is 0, the system is shutting down or restarting (it is not possible to determine which event is occurring).
If the parameter is ENDSESSION_CLOSEAPP (0x00000001), the application is using a file that must be replaced, the system is being serviced, or system resources are exhausted.
If the parameter is ENDSESSION_CRITICAL (0x40000000), the application is forced to shut down.
If the parameter is ENDSESSION_LOGOFF (0x80000000), then the user is logging off.
uj5u.com熱心網友回復:
lParam 值,關機、 重啟沒作區分,均為 0uj5u.com熱心網友回復:
我遇到類似問題,可以通過捕獲訊息但是關機和重啟的值都是0,樓主找到辦法了嗎。我還嘗試了讀取日志,但是因為在日志寫入關機或者重啟事件的時間是在程式結束運行以后,所以始終不能去的本次關機和重啟事件的區別轉載請註明出處,本文鏈接:https://www.uj5u.com/gongcheng/59502.html
標籤:基礎類
