Adding a Windows 7 Application Manifest to your application

 

转自:http://blogs.msdn.com/ukisvdev/archive/2009/09/23/adding-a-windows-7-application-manifest-to-your-application.aspx

 

One of the most important things you can do to make an application compatible with Windows 7 is to add an application manifest to it. When you do this, you are telling Windows that you have tested your application on Windows 7 and that there is no need for it to run application compatibility ‘features’ such as UAC virtualization and the Program Compatibility Assistant.

There are a number of ways to add a manifest, you can do it from within Visual Studio 2008 by simply selecting Add -> New Item… to the project, and selecting Application Manifest File, and for earlier versions of Visual Studio you can simply add it as a resource of type RT_MANIFEST, or you can use the mt.exe tool in the Windows SDK to add it to the compiled executable – before you have signed it of course.

If you are using the mt.exe tool it’s best to extract any existing manifest first, as one may already be included for XP Styles or Side-by-Side COM components.

You can extract an application manifest from an executable by running the following command: mt -inputresource:myapp.exe;#1 -out:myapp.manifest

You can then add the Windows 7 manifest shown below back into the executable using the following command:  mt -manifest myapp.manifest -outputresource:myapp.exe;#1

<?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%22>
  <assemblyIdentity version="1.0.0.0" name="MyApplication.app"/>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges xmlns="urn:schemas-microsoft-com:asm.v3">
        <requestedExecutionLevel level="asInvoker" uiAccess="false" />
      </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application>
  </compatibility>
</asmv1:assembly>

posted @ 2009-12-14 13:00  建峰  阅读(650)  评论(0编辑  收藏  举报