Microsoft还提供了更多的信息:Application Manifests.它甚至包含一个示例清单,您可以将其简单地复制并粘贴到一个空白的文本文件中以开始使用.
重要的是,如果您希望应用程序提示用户标高,则将requestedExecutionLevel设置为requireAdministrator,而不是asInvoker.有关使用UAC的清单的具体信息可用here.
所以一个完整的样本可能看起来像这样:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity version="1.0.0.0" processorArchitecture="*" name="MyMagicalApplication" type="win32" /> <description>Sample manifest for your super cool application</description> <!-- Request version 6 of the common controls. --> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="*" publicKeyToken="6595b64144ccf1df" language="*" /> </dependentAssembly> </dependency> <!-- Identify the application security requirements. --> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false" /> </requestedPrivileges> </security> </trustInfo> </assembly>
将清单嵌入到可执行文件中的传统方式是使用mt.exe
utility作为Windows SDK的一部分.
VBAccelerator site还有一些关于在VB 6应用程序中嵌入清单的信息.具体来说,它说:
There are two ways to provide the manifest: the simplest (but least elegant) way is to provide the manifest on disk for an executable. Let’s say your application is called TimeSlot.exe. Then if you save the manifest XML above as
06001
in the same directory as the executable,TimeSlot.exe will automatically get the XP styles. VB5 and VB6 examples are provided. If you rename the .manifest file prior to running the app,you can switch off the XP styles.
A more robust method is to compile the manifest as a resource in your application. To do this,the manifest must appear as resource type
RT_MANIFEST
(24) with idCREATEPROCESS_MANIFEST_RESOURCE_ID
(1). For some bizarre reason,you must also ensure that the resulting XML file is an even multiple of 4 bytes long. So for example,if your file is actually 597 bytes you need to add padding spaces to make up the file size to 600 bytes before compiling. The Resource examples demonstrate how to create this resource file using a resource compiler script (.rc file) and RC.exe.
但是,如果您希望在从VB 6 IDE构建应用程序时自动嵌入清单,那么您将遇到更多困难. VB 6 IDE不支持后期制作步骤,因此您无法在命令行上简单地运行mt.exe来为您执行此操作.有几个在网页上看到的实用程序,声称自动为您自动嵌入清单,但我相信大多数实用程序是只处理请求v6 ComCtl32.dll的旧实用程序.我不知道他们是否容易扩展,以包括UAC权限,但这是值得一提的.这里有一些链接要查看:
> http://vb6zone.blogspot.com/2010/07/make-my-manifest.html
> http://sourceforge.net/projects/ummm/
> http://www.vbforums.com/showthread.php?t=606736
> http://www.vbforums.com/showthread.php?t=430886