Delphi 7 vista / windows 7 manifest

社会主义新天地 提交于 2019-11-28 16:35:16

Here are the steps:

1. Remove XPMan: Remove any reference to XPMan component in your project. XPMan adds a default manifest to the executable that prevents Windows to see our customized manifest. You shouldn't be worried about XP Theme provided by XPMan, theme support is preserved in the following manifest.

2. Create the customized manifest: Create a file like Win7UAC.manifest in the project directory (the filename really doesn't matter). add the following lines to Win7UAC.manifest:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32" name="App" version="3.1.0.0" processorArchitecture="*"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
    </dependentAssembly>
  </dependency>
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
        </requestedPrivileges>
    </security>
  </trustInfo>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
    <application>
      <!--The ID below indicates application support for Windows Vista -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
      <!--The ID below indicates application support for Windows 7 -->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
    </application>
  </compatibility>
</assembly>

You can add more items to this manifest. You can also remove Microsoft.Windows.Common-Controls parts to disable the theme support.

3. Compile manifest to a resource: Create a file named Win7UAC.rc in the project directory that contains one line as:

1 24 "Win7UAC.manifest"

To compile this file, go to cmd, point to project directory and run following command:

brcc32.exe Win7UAC.rc

4. Add resource (the manifest) to the project: Just add the following line anywhere you want in one of the unit files of the project:

{$R 'Win7UAC.res'}

A suitable place for adding this line is in the project main file (usually named Project1.dpr) and under the {$R *.res} line.

5. Rebuild the project

6. Remember whenever you add XPMan component to any of project units, this UAC manifest will not work properly.

Here are some informative links

Vista UI mainfest

Delphi and Windows Vista User Account Control

<?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"
        publicKeyToken="6595b64144ccf1df"
        language="*"
        processorArchitecture="x86" />
    </dependentAssembly>
  </dependency>

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="highestAvailable"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>

This works fine for me:

<?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"
          publicKeyToken="6595b64144ccf1df"
          language="*"
          processorArchitecture="x86"
        />
    </dependentAssembly>
  </dependency>

  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel level="highestAvailable" />
      </requestedPrivileges>
    </security>

</assembly>

Using Delphi XE, I had to uncheck 'Enable runtime themes' in 'Project' -> 'Options' -> 'Application' tab for this to work.

Edit: sorry, does seems to work with this option enabled.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!