⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 pddnotify.cpp

📁 此代码为WCE5.0下电源管理的源代码
💻 CPP
字号:
//
// Copyright (c) Microsoft Corporation.  All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//

#include <pmimpl.h>

// accesses to this variable should be protected by the PM lock
extern "C" extern POWER_BROADCAST_POWER_INFO gSystemPowerStatus;

// This routine is called whenever a client requests some form of notifications from
// the PM.  In some cases it may be appropriate to send an immediate notification
// or take other action on behalf of the client.  The caller of this routine must
// hold the PM lock.
VOID
PlatformSendInitialNotifications(PPOWER_NOTIFICATION ppn, DWORD dwFlags)
{
    POWER_BROADCAST_BUFFER pbb;

    // The only notifications we need to process when they are requested 
    // is battery notifications.  This allows the client to immediately
    // synchronize with the current system power status.
    if((dwFlags & PBT_POWERSTATUSCHANGE) != 0) {
        // send a notification if the line status is known
        if(gSystemPowerStatus.bACLineStatus == AC_LINE_OFFLINE
        || gSystemPowerStatus.bACLineStatus == AC_LINE_ONLINE) {
            pbb.Message = PBT_POWERSTATUSCHANGE;
            pbb.Flags = 0;
            pbb.Length = 0;
            pbb.SystemPowerState[0] = 0;
            SendNotification(ppn, (PPOWER_BROADCAST) &pbb, sizeof(POWER_BROADCAST));
        }
    }

    // Send a PBT_POWERINFOCHANGE notification with whatever we know about power status.
    if((dwFlags & PBT_POWERINFOCHANGE) != 0) {
        PPOWER_BROADCAST_POWER_INFO ppbpi = (PPOWER_BROADCAST_POWER_INFO) &pbb.SystemPowerState[0];
        
        // update the notification buffer
        pbb.Message = PBT_POWERINFOCHANGE;
        pbb.Flags = 0;
        pbb.Length = sizeof(*ppbpi);
        *ppbpi = gSystemPowerStatus;
        SendNotification(ppn, (PPOWER_BROADCAST) &pbb, pbb.Length + (3 * sizeof(DWORD)));
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -