> ## Documentation Index
> Fetch the complete documentation index at: https://devdocs.xbox.com/llms.txt
> Use this file to discover all available pages before exploring further.

# 在 PC 上支持高 DPI 显示器

> 通过程序集清单为你的 PC 作品启用 Per-Monitor V2 DPI 感知,以便在高 DPI Windows 显示器上正确渲染并处理鼠标输入。

为帮助 Windows 10 应用程序与外壳元素在不同像素密度的显示器上呈现一致的大小,Windows 内置了缩放设置。要让你的作品在这些缩放设置被调整后仍能正确渲染和处理鼠标输入,请设置默认的 DPI 感知。如果不这样做,你的作品可能显示不正确,导致高 DPI 显示器用户无法正常使用。

## 启用高 DPI 感知

#### 确保作品支持高 DPI 显示器

1. 检查游戏可执行文件的程序集清单 XML。可能是 titleName.exe、与 titleName.exe 并列的清单文件,或者内嵌在游戏可执行文件中的清单。可以在命令行中使用 [sigcheck](https://learn.microsoft.com/sysinternals/downloads/sigcheck) 从游戏可执行文件中提取内嵌清单(如下所示)。
   ```cpp theme={null}
   sigcheck -m titleName.exe
   ```
2. 如果清单 XML 中只看到以下 `<dpiAware>` 标签,则未支持高 DPI 显示器。
   ```cpp theme={null}
   <windowsSettings>
       <dpiAware>
           true
       </dpiAware>
   </windowsSettings>
   ```
3. 内嵌清单优先于外部清单。若存在内嵌清单,请转到第 4 步。若没有内嵌清单,请创建一个 titleName.exe.manifest 文件,内容如下。
   ```cpp theme={null}
   <?xml version="1.0" encoding="UTF-8" standlone="yes"?>
   <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
   <application xmlns="urn:schemas-microsoft-com:asm.v3">
       <windowsSettings>
           <dpiAwareness xmlns="https://schemas.microsoft.com/SMT/2016/WindowsSettings">
               PerMonitorV2
           </dpiAwareness>
       </windowsSettings>
   </application>
   </assembly>
   ```
4. 如果存在内嵌清单,请在命令行中使用 Windows SDK 中的以下 [Mt.exe](https://learn.microsoft.com/windows/win32/sbscs/mt-exe) 工具找到它。
   ```cpp theme={null}
   mt -inputresource:<titleExeFilename> -out:<manifestOutputFilename>
   ```
5. 编辑内嵌清单,添加新的 `<dpiAwareness>` 标签(如下所示)。
   ```cpp theme={null}
   <windowsSettings>
       <dpiAwareness xmlns="https://schemas.microsoft.com/SMT/2016/WindowsSettings">
           PerMonitorV2
       </dpiAwareness>
   </windowsSettings>
   ```
6. 通过 Windows SDK 中的以下 [Mt.exe](https://learn.microsoft.com/windows/win32/sbscs/mt-exe) 工具在命令行中更新内嵌清单。
   ```cpp theme={null}
   mt -updateresource:<titleExeFilename> -manifest <manifestFilename>
   ```

你的作品现在支持高 DPI 显示器了。

## 验证高 DPI 感知

#### 确认作品支持高 DPI 显示器

1. 在具有高 DPI 显示器的 PC(例如 Surface Studio 2)上,进入 **设置** > **显示**,并将缩放设为 **150%**。
2. 启动你的作品。
3. 检查存在光标的画面,确认作品显示如预期。例如,全屏作品应占满整个屏幕。
4. 在屏幕上移动光标,确保它能到达作品窗口的整个可视区域。
5. 悬停在交互式 UI 元素(如按钮)上,确认视觉状态与交互如预期。例如,只有当光标正好悬停在按钮上时才应改变视觉状态,而不是靠近时。

## 注意

* 禁用注册表虚拟化有时被作为高 DPI 感知问题的解决方案提出,但我们不建议这样做。
* Visual Studio 的 Configuration Properties 中有一个 DPI Awareness 选项,但它使用较旧的 `<dpiAware>` 标签,对 MSIXVC 打包的作品无效。

## 参见

[Setting the default DPI awareness for a process](https://learn.microsoft.com/previous-versions/windows/desktop/legacy/mt846517\(v=vs.85\))


## Related topics

- [XAG 101：文本显示](/zh-CN/build/game-principles/accessibility/xag-deep-dives/xag-101-text-display.md)
- [XR-131 Game DVR 与截屏的显示模式支持](/zh-CN/publishing/certification/xr/xr-131.md)
- [视频捕获 (wdcapturesession.exe)](/zh-CN/tools/tools-pc/commandlinetools/gr-wdcapturesession.md)
- [XDisplayHdrModePreference](/zh-CN/reference/system/xdisplay/enums/xdisplayhdrmodepreference.md)
- [Screen Capture (wdcapture.exe)](/zh-CN/tools/tools-pc/commandlinetools/gr-wdCapture.md)
