需要dpiAware可执行文件才能在Windows XP / 2003中运行

时间:2013-02-26 18:20:07

标签: winforms manifest windows-server-2003 dpi

我有一些需要在XP / 2003 / Vista / 7/2008 / 8/2012上运行的Windows窗体应用程序,当用户选择大字体或更高的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函数)?

1 个答案:

答案 0 :(得分: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