确定平台是移动平台还是桌面平台

TMM 仅在移动计算机上运行,并在台式计算机上自动禁用。 硬件供应商应启用并使用自己的专有方法在台式计算机上进入克隆视图。 他们应确定平台是否为移动平台,以避免使用其专有方法在移动计算机上进入克隆视图,转而使用 TMM。

硬件供应商可以使用以下代码来确定平台是移动平台还是桌面平台。 然后,平台可以使用适当的机制进入克隆视图。

#include <Powrprof.h>   // For GetPwrCapabilities

    BOOL IsMobilePlatform()
    {
        BOOL fIsMobilePlatform = FALSE;

        fIsMobilePlatform = (PlatformRoleMobile == PowerDeterminePlatformRole());

        POWER_PLATFORM_ROLE iRole;

        // Check if the operating system determines 
        // that the computer is a mobile computer.
        iRole = PowerDeterminePlatformRole();

        if (PlatformRoleMobile == iRole)
        {
            fIsMobilePlatform = TRUE;
        }
        else if (PlatformRoleDesktop == iRole) 
        // Can happen when a battery is not plugged into a laptop
        {
            SYSTEM_POWER_CAPABILITIES powerCapabilities;

            if (GetPwrCapabilities(&powerCapabilities))
            {
         // Check if a battery exists, and it is not for a UPS.
         // Note that SystemBatteriesPresent is set on a laptop even if the battery is unplugged.
                fIsMobilePlatform = ((TRUE == powerCapabilities.SystemBatteriesPresent) && (FALSE == powerCapabilities.BatteriesAreShortTerm));
            }
            // GetPwrCapabilities should never fail 
            // However, if it does, leave fReturn == FALSE.
        }

        return fIsMobilePlatform;
    }

有关上述代码中调用的函数的信息,请参阅Microsoft Windows SDK文档。