wince 休眠问题解决

mobile 在长时间没有操作的时候进入待机状态:

进入待机状态之后,所有进程都进入停止状态,调用电源管理可以解决这个问题:

 

If you want your program to not be put to sleep while it's running, the best way is to create a KeepAlive type function that calls SystemIdleTimerReset, SHIdleTimerReset and simulates a key touch. Then you need to call it a lot, basically everywhere.

  
  
 
  
{ 
     WINAPI (); 
}; 
 
 () 
{ 
     DWORD  = ; 
    DWORD  = (); 
     (( - ) >  ||  < )  
    { 
        (); 
        (); 
        keybd_event(VK_LBUTTON, , KEYEVENTF_SILENT, ); 
        keybd_event(VK_LBUTTON, , KEYEVENTF_KEYUP | KEYEVENTF_SILENT, ); 
         = ; 
    } 
} 

This method only works when the user starts the application manually.

If your application is started by a notification (i.e. while the device is suspended), then you need to do more or else your application will be suspended after a very short period of time until the user powers the device out of suspended mode. To handle this you need to put the device into unattended power mode.

(!:: (PPN_UNATTENDEDMODE, TRUE)) 
{ 
     
} 
 
 
 
(!:: (PPN_UNATTENDEDMODE, FALSE)) 
{ 
     
} 

During unattended mode use, you still need to call the KeepAlive a lot, you can use a separate thread that sleeps for x milliseconds and calls the keep alive funcation.

Please note that unattended mode does not bring it out of sleep mode, it puts the device in a weird half-awake state.

So if you start a unattended mode while the device in suspended mode, it will not wake up the screen or anything. All unattended mode does is stop WM from suspending your application. Also the other problem is that it does not work on all devices, some devices power management is not very good and it will suspend you anyway no matter what you do.

 

 

 

转载于:https://www.cnblogs.com/zoushigang7/archive/2010/07/21/1782137.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值