zoukankan      html  css  js  c++  java
  • 如何在系统休眠的情况下保持特殊设备供电(如GPS供电)

    在PPC上当系统休眠的时候会把很多设备的电源关掉,但是一些应用程序需要一些设备一直工作供电,比如GPS.但是MS官方说的这就需要其它的处理.SetPowerRequirement并不能解决问题,调用该函数在系统断电的时候还是会把指定的设备电源切掉.

    正确的做法应该是这样.

    1SetPowerRequirement把需要供电的设备名称定好,比如GPS设备一般就是"GPD0:";

    2CreateMsgQueue建立消息队列ptr = CreateMsgQueue(L"PtrSvsPowerNotify", &options);

    3PowerNotifyHandle = RequestPowerNotifications(ptr, PBT_TRANSITION);

    4一般需要另外起一个线程

    res =WaitForSingleObject(ptr, 29000);

     if (res == 0)
                        {
                            ReadMsgQueue(ptr, buffer, 1000, ref nRead, WinAPI.INFINITE, ref flags);
                            POWER_BROADCAST pb;

    5.判断pb.SystemPowerState是不是"unattended"如果是则调用PowerPolicyNotify(WinAPI.PPN_UNATTENDED, 1);

    按照以上的步骤就可以实现当系统休眠的时候指定的设备不会断电了.(该方法在HTC3300机型上试验通过)

                                         

  • 相关阅读:
    博客园代码
    前端
    1338. Reduce Array Size to The Half
    1220. Count Vowels Permutation
    363. Max Sum of Rectangle No Larger Than K
    366. Find Leaves of Binary Tree
    443. String Compression
    8 · Rotate String
    886. Possible Bipartition
    LT 183 wood cut
  • 原文地址:https://www.cnblogs.com/javawebsoa/p/2458397.html
Copyright © 2011-2022 走看看