共用方式為


判斷平臺是否為行動裝置或桌面

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檔。