C++ Builder / Delphi 2010 应用程序清单模板
Posted
技术标签:
【中文标题】C++ Builder / Delphi 2010 应用程序清单模板【英文标题】:C++ Builder / Delphi 2010 application manifest template 【发布时间】:2014-10-21 14:33:01 【问题描述】:在谷歌上搜索了很多以至于我头晕目眩以及一堆误导和矛盾的信息之后,我设法为应用程序清单编译了以下最小“模板”,它应该定义以下内容:
程序版本和名称 它不需要任何特殊的管理员权限 它与 Windows Vista 到 Windows 8.1 兼容 它支持 DPI我的清单文件是否足以满足上述目的?我是否有任何错误需要注意?我特别对 xmlns 命名空间版本以及为什么它们在此清单的某些部分不同的原因感到困惑?
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly manifestVersion="1.0" xmlns="urn:schemas-microsoft-com:asm.v1" xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<assemblyIdentity type="win32"
name="Manufacturer.Division.ApplicationName"
version="1.2.3.4"
processorArchitecture="x86"
/>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="e2011457-1546-43c5-a5fe-008deee3d3f0"/> <!-- The application supports Windows Vista and Windows Server 2008 -->
<supportedOS Id="35138b9a-5d96-4fbd-8e2d-a2440225f93a"/> <!-- The application supports Windows 7 and Windows Server 2008 R2 -->
<supportedOS Id="4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38"/> <!-- The application supports Windows 8 and Windows Server 2012 -->
<supportedOS Id="1f676c76-80e1-4239-95bb-83d0f6d0da78"/> <!-- The application supports Windows 8.1 and Windows Server 2012 R2 -->
</application>
</compatibility>
<asmv3:application xmlns:asmv3="urn:schemas-microsoft-com:asm.v3">
<asmv3:windowsSettings xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">
<dpiAware>true</dpiAware>
</asmv3:windowsSettings>
</asmv3:application>
</assembly>
编辑:这是我的最终清单文件模板,基于此处的帮助和未来谷歌员工的进一步研究。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32"
processorArchitecture="*"
version="1.2.3.4"
name="Manufacturer.Division.ApplicationName"
/>
<description>My Application Description</description>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<supportedOS Id="e2011457-1546-43c5-a5fe-008deee3d3f0"/> <!-- Windows Vista and Windows Server 2008 -->
<supportedOS Id="35138b9a-5d96-4fbd-8e2d-a2440225f93a"/> <!-- Windows 7 and Windows Server 2008 R2 -->
<supportedOS Id="4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38"/> <!-- Windows 8 and Windows Server 2012 -->
<supportedOS Id="1f676c76-80e1-4239-95bb-83d0f6d0da78"/> <!-- Windows 8.1 and Windows Server 2012 R2 -->
</application>
</compatibility>
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">True/PM</dpiAware>
</windowsSettings>
</application>
</assembly>
2019 年编辑:对于 DPI 感知 V2,需要按照此处所述进行更改:
How can I set the dpiAware property in a Windows application manifest to "per monitor" in Visual Studio?
所以这部分发生了变化:
<application xmlns="urn:schemas-microsoft-com:asm.v3">
<windowsSettings>
<dpiAware xmlns="http://schemas.microsoft.com/SMI/2005/WindowsSettings">true/pm</dpiAware> <!-- fallback for Windows 7 and 8 -->
<dpiAwareness xmlns="http://schemas.microsoft.com/SMI/2016/WindowsSettings">permonitorv2,permonitor</dpiAwareness> <!-- falls back to per-monitor if per-monitor v2 is not supported -->
<gdiScaling xmlns="http://schemas.microsoft.com/SMI/2017/WindowsSettings">true</gdiScaling> <!-- enables GDI DPI scaling (if needed, otherwise leave out) -->
</windowsSettings>
</application>
【问题讨论】:
+1 包括最终清单,考虑到未来的谷歌员工 - 谢谢。 【参考方案1】:如果您想启用 Visual Styles,您的清单未启用 ComCtrl v6:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<!-- your assemblyIdentity element ... -->
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
processorArchitecture="*"
publicKeyToken="6595b64144ccf1df"
language="*"
/>
</dependentAssembly>
</dependency>
<!-- your trustInfo, compatibility, application elements ... -->
</assembly>
您不需要在*** assembly
元素上声明 xmlns:asmv3
,因为它正在 application
元素上重新声明。
使用的 XML 命名空间是不同的,因为它们是由不同的 API 定义的。清单文件不是单个 API,它是多个 API 值的集合,在一个集中位置进行控制。
【讨论】:
以上是关于C++ Builder / Delphi 2010 应用程序清单模板的主要内容,如果未能解决你的问题,请参考以下文章
在 Delphi & C++ Builder 中安装 VCL 组件
我应该在 Delphi 而不是 C++ Builder 中编写组件吗?如何向组件添加事件?