windows显示驱动开发-多监视器管理器(三)

处理现有的监视器配置

除了在双监视器配置中检测新监视器和启动暂时性多监视器管理器 (TMM) 对话框外,TMM 还必须还原以前的显示配置。 TMM 可以通过 IViewHelper::SetConfiguration 方法将显示数据传递给用户模式显示驱动程序来还原显示配置。 TMM 将分配内存,并将显示模式和拓扑信息存储在内存中。 TMM 在 SetConfiguration的 pIStream 参数指向的 IStream 接口中传递此内存。 用户模式显示驱动程序还可以修改或折叠其他显示数据 (例如 gamma 或电视设置) 。 驱动程序完成显示数据后,驱动程序将调用 IStream::Release 方法来释放内存。

下图显示了 TMM 还原现有监视器配置时发生的操作流。

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

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;
    }
相关推荐
繁华似锦respect4 分钟前
C++ 设计模式之观察者模式详细介绍
linux·开发语言·c++·windows·观察者模式·设计模式·visual studio
用户61354114601610 分钟前
Windows 安装 Grafana 看板详细步骤
windows
IDOlaoluo31 分钟前
Windows 安装 Grafana 看板详细步骤
windows·grafana
范纹杉想快点毕业1 小时前
《STM32深度100问:AI助教工程师的实战问答录》从入门到精通适用入门嵌入式软件初级工程师,筑牢基础,技术积累
arm开发·数据库·驱动开发·mongodb·fpga开发
s***11701 小时前
Node.JS 版本管理工具 Fnm 安装及配置(Windows)
windows·node.js
n***85942 小时前
ANSYS Electronics 2025 R1软件安装教程+安装包下载
windows·学习
爱吃山竹的大肚肚2 小时前
根据每个键对应的列表里所有实体的 count 最大值,将整个字典从大到小重新排列
linux·运维·windows
赖small强2 小时前
【Linux驱动开发】Linux虚拟文件系统(VFS)技术架构深度解析
linux·驱动开发·vfs·inode·ext4·superblock·目录项
love530love2 小时前
【SD WebUI踩坑】启动报错 Expecting value: line 1 column 1 (char 0) 的终极解决方案
人工智能·windows·python·github·stablediffusion
繁华似锦respect2 小时前
C++ 设计模式之代理模式详细介绍
linux·开发语言·c++·windows·设计模式·代理模式·visual studio