Note that there are some explanatory texts on larger screens.

plurals
  1. POCan't catch sleep/suspend messages (winXP)
    primarykey
    data
    text
    <p>My app needs to block sleep/hibernate mode. I have the code in place, but after successfully catching the <strong>WM_POWERBROADCAST</strong> message, neither <strong>PBT_APMQUERYSUSPEND</strong> nor <strong>PBT_APMQUERYSTANDBY</strong> are being caught successfully. Interestingly, the <strong>PBT_APMRESUMECRITICAL</strong> and <strong>PBT_APMRESUMEAUTOMATIC</strong> messages <em>are</em> being caught by my app.</p> <p>Bottom line question: is there any reason why my app would fail to catch the standby/suspend messages, but succeed in catching the resume messages?</p> <p>This <a href="https://stackoverflow.com/questions/629240/prevent-windows-from-going-into-sleep-when-my-program-is-running">Q&amp;A</a> [stackoverflow.com] helped, btw, but again, the messages don't seem to be making it to my app.</p> <p>My code (w/ event logging code removed for brevity):</p> <pre><code> protected override void WndProc(ref System.Windows.Forms.Message m) { // Power status event triggered if (m.Msg == (int)NativeMethods.WindowMessage.WM_POWERBROADCAST) { // Machine is trying to enter suspended state if (m.WParam.ToInt32() == (int)NativeMethods.WindowMessage.PBT_APMQUERYSUSPEND || m.WParam.ToInt32() == (int)NativeMethods.WindowMessage.PBT_APMQUERYSTANDBY) { // Have perms to deny this message? if((m.LParam.ToInt32() &amp; 0x1) != 0) { // If so, deny broadcast message m.Result = new IntPtr((int)NativeMethods.WindowMessage.BROADCAST_QUERY_DENY); } } return; // ?! } base.WndProc(ref m); } </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload