Visual Studio 中可执行文件中嵌入的清单文件

概要
本分步指南介绍如何在 Microsoft Visual Studio 2005年中的可执行文件 (.exe) 文件中嵌入的清单文件。如果您要开发"认证 Windows Vista"程序,您需要将清单文件嵌入在可执行文件。
更多信息
在本文中,占位符appname是指一个示例应用程序。appname占位符应该替换应用程序的真实名称。

若要将清单文件嵌入在可执行文件,请执行以下步骤 ︰
  1. 在 Visual Studio 2005 中,打开该应用程序。
  2. 单击生成菜单上的配置管理器。
  3. 在配置管理器窗口中,确定活动解决方案平台列表中是否已存在的x86项。
    • 如果x86项不存在,则转到步骤 4。
    • 如果x86项已经存在, < 编辑...>列表中选择活动解决方案平台。编辑解决方案平台对话框中,单击x86,单击删除,然后单击关闭。
  4. 在配置管理器窗口中,选择活动解决方案平台列表中的< 新建...> 。
  5. 新建解决方案平台对话框中,类型x86在键入或选择新的平台中,从从此处复制设置列表中选择< 空 > ,单击以清除创建新的项目平台复选框,然后单击确定。
  6. 在配置管理器窗口中,单击关闭。

    注意:如果要使用后期生成脚本来调用 MT.exe 文件,删除后的生成脚本。在这种情况下,您不需要调用 MT.exe 文件嵌入的清单文件。
  7. 单击生成菜单上的重新生成解决方案。
  8. 文件菜单上,单击关闭解决方案。
  9. 启动记事本,然后在新文档中粘贴以下代码(其中J2534Tool为appname)︰
    <?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="x86" 
      name="J2534Tool.exe.manifest" 
      type="win32" 
    /> 
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 
      <security> 
        <requestedPrivileges> 
            <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> 
        </requestedPrivileges> 
      </security> 
    </trustInfo> 
    </assembly>
  10. 文件菜单上单击另存为,然后将此文件另存为appname。 exe.manifest。
  11. 文件菜单上,单击关闭。
  12. 在 Visual Studio 2005 中,打开appname.exe文件。树视图显示。
  13. 单击appname.exe节点,然后单击添加资源。
  14. 添加资源对话框中,单击导入,找到appname。 exe.manifest 文件中,并单击打开。
  15. 自定义资源类型对话框中,键入RT_MANIFEST,,然后单击确定。
  16. 属性面板中,从"101"到"1"的ID属性值的更改。

    注意:
  17. 文件菜单上,单击全部保存。
如果appname.exe文件是一个 ClickOnce 部署应用程序的一部分,则必须更新 ClickOnce 应用程序清单文件和部署清单文件。

如果使用 Mage.exe,打开一个命令提示符访问存储 Mage.exe 目录,然后运行以下两个命令 ︰
mage.exe-u destination directory of the appname.exe.manifest fileappname.exe.manifest -名称"AppName"-版本application version-FromDirectory the source directory of the appname.exe.manifest file-cfdirectory of the .pfx filename.pfx -pwd"password"

mage.exe-udirectory of the .application fileappname.application -appm directory of the appname.exe.manifest fileappname.exe.manifest -cfdirectory of the .pfx filename.pfx -pwd"password"

 

原文地址:https://www.cnblogs.com/MrYuan/p/5455338.html