3

我有一些 Windows 窗体应用程序需要在 XP/2003/Vista/7/2008/8/2012 上运行,并且当用户选择大字体或更高 DPI 时应该仍然看起来不错。在 app.manifest 中启用 DPI 感知适用于 Vista 及更高版本,但在 XP/2003 上,由于清单条目不受支持,应用程序会报告错误。

<?xml version="1.0" encoding="utf-8"?>
<asmv1:assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv1="urn:schemas-microsoft-com:asm.v1" xmlns:asmv2="urn:schemas-microsoft-com:asm.v2" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
  <asmv1:application>
    <asmv1:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>true</dpiAware>
    </asmv1:windowsSettings>
  </asmv1:application>
</asmv1:assembly>

在 Windows 2003 上使用该清单运行应用程序会导致以下错误消息:

This application has failed to start because the application
configuration is incorrect.

并记录此 Windows 事件消息:

The element asmv1:application appears as a child of element
urn:schemas-microsoft-com:asm.v1^assembly which is not supported
by this version of Windows.

是否可以以允许 XP/2003 忽略它们不支持的这部分清单的方式声明清单?或者我必须删除清单并对 SetProcessDPIAware 进行有条件的调用(即使我读过的所有内容都建议不要使用该 API 函数)?

4

1 回答 1

0

我最终得到了这个清单

<?xml version='1.0' encoding='UTF-8' standalone='yes'?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<dependency>
    <dependentAssembly>
        <assemblyIdentity
            type="win32"
            name="Microsoft.Windows.Common-Controls"
            version="6.0.0.0"
            processorArchitecture="x86"
            publicKeyToken="6595b64144ccf1df"
            language="*"
        />
    </dependentAssembly>
</dependency>
  <asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
    <asmv3:windowsSettings
         xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
      <dpiAware>True/PM</dpiAware>     
    </asmv3:windowsSettings>
  </asmv3:application>
</assembly>

Delphi 特定条件:使用运行时主题已关闭且 xpman.pas 未在任何地方使用

于 2016-05-20T10:41:54.090 回答