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;
    }
相关推荐
装杯让你飞起来啊10 小时前
第 4 周 Unit 2:Jetpack Compose 状态、按钮、计数器与小费计算器
windows·microsoft·kotlin·安卓
菜鸟的日志10 小时前
【嵌入系统】嵌入式学习笔记(一)
windows·笔记·嵌入式硬件·学习·ubuntu·操作系统
深念Y10 小时前
装了 PowerShell 7 还是乱码?
windows·乱码·终端·命令行
相国11 小时前
在Windows里通过WSL安装Ubuntu 22.04
linux·windows·ubuntu·wsl
x***r15112 小时前
phpwind_UTF8_8.5部署步骤详解(附PHPWind论坛搭建与本地环境配置)
windows
酿情师13 小时前
网络攻防技术:Windows操作系统的攻防
网络·windows
倔强的石头10613 小时前
kingbase备份与恢复实战(六)—— 备份自动化与保留策略:Windows任务计划+日志追溯
运维·windows·自动化
枳实-叶13 小时前
【Linux驱动开发】第三天:上下文核心概念全解 —— 进程/中断上下文+切换开销+TLB刷新原理
linux·驱动开发
FL162386312914 小时前
基于yolo26实现的免安装环境windows版一键训练工具
windows
YJlio14 小时前
8.2Windows 11 如何用 Xbox Game Bar 实时监测电脑性能?CPU、内存、GPU、显存与 FPS 瓶颈判断教程
windows·笔记·学习·chatgpt·架构·电脑·xbox