全國最多中醫師線上諮詢網站-台灣中醫網
發文 回覆 瀏覽次數:2046
推到 Plurk!
推到 Facebook!

如何由程式定時自動由Suspend/Hibernation模式回復正常?

尚未結案
chris_shieh
高階會員


發表:46
回覆:308
積分:240
註冊:2004-04-26

發送簡訊給我
#1 引用回覆 回覆 發表時間:2004-06-10 14:54:57 IP:218.167.xxx.xxx 未訂閱
小弟目前知道關於Power Management API可以利用 1. GetSystemPowerStatus取得系統電源管理狀態 2. SetSystemPowerState設定系統電源管理狀態進入suspend/hibernation 3. 利用 WM_POWERBROADCAST 攔截有關電源管理變化的message 藉由判斷 message.wParam 已得知電源管理訊息 PBT_APMBATTERYLOW Battery power is low. PBT_APMOEMEVENT OEM-defined event occurred. PBT_APMPOWERSTATUSCHANGE Power status has changed. PBT_APMQUERYSUSPEND Request for permission to suspend. PBT_APMQUERYSUSPENDFAILED Suspension request denied. PBT_APMRESUMECRITICAL Operation resuming after critical suspension. PBT_APMRESUMESUSPEND Operation resuming after suspension. PBT_APMSUSPEND System is suspending operation. 並經由Result=BROADCAST_QUERY_DENY 拒絕電源管理動作 (=True 同意) 小弟想要請教的是:如何由程式在系統進入suspend/hibernation後定時自動resume回來, 目前相關文件MSDN等都只提到 user event回復. 但是程式在系統進入suspend/hibernation後如何還能模擬user event 呢? 謝謝
chris_shieh
高階會員


發表:46
回覆:308
積分:240
註冊:2004-04-26

發送簡訊給我
#2 引用回覆 回覆 發表時間:2004-06-10 17:20:37 IP:219.68.xxx.xxx 未訂閱
自己找了一下 http://msdn.microsoft.com/library/default.asp?url=/library/en-us/power/base/system_wake_up_events.asp 應該就是方法了吧. System Wake-up Events ====================== Your application can restore an On-Now capable computer that is in a sleeping state to the working state by using a scheduled time or a device event. This is known as a wake-up event. Use a waitable timer object to specify the time at which the system should wake. To create the object, use the CreateWaitableTimer function. To set the timer, use the SetWaitableTimer function. The pDueTime parameter specifies when the timer will be signaled. To specify that the system should wake when the timer is signaled, set the fResume parameter to TRUE. When the system wakes automatically because of an event (other than power switch or user activity), the system automatically sets its idle timer to at least 1 minute. This timer allows applications to call the SetThreadExecutionState function to indicate that they are busy. This enables the system to shut down without affecting the user. The following criteria determine whether a system shutdown is needed: If the system wakes automatically, it shuts down as soon as the last job is completed, as indicated by the process calling SetThreadExecutionState. If the system wakes automatically, but the user provides new input while the event is handled, the system does not shut down when the last job finishes. If the system is on and the user is active, the system does not enter the sleeping state. If the system is on, no applications are busy, and the user is inactive for a long time, the system enters the sleeping state when the timer expires. When the system wakes automatically, the system broadcasts the PBT_APMRESUMEAUTOMATIC event to all applications. Because the user is not present, most applications should do nothing. Event-handling applications, such as fax servers, should handle their events. If you wish to determine whether the system is in this state, call the IsSystemResumeAutomatic function. If the system wakes due to user activity after broadcasting PBT_APMRESUMEAUTOMATIC, the system broadcasts the PBT_APMRESUMESUSPEND event and turns on the display. Your application should reopen files that it closed when the system entered the sleeping state, and it should prepare for user input. If an application called SetSystemPowerState with fForce set to TRUE, no applications will receive the PBT_APMQUERYSUSPEND event when the system enters the sleeping state. If the system is carrying out a critical suspension, no applications will receive the PBT_APMQUERYSUSPEND or PBT_APMSUSPEND event; they will receive only the PBT_APMRESUMECRITICAL event. 如果哪位大大發現小弟用錯方法, 或有更好方法 請不吝指教
系統時間:2024-05-16 8:42:02
聯絡我們 | Delphi K.Top討論版
本站聲明
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。
2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。
3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇!