0

我使用 .manifest 文件为我的应用程序添加了管理员权限,因为我需要访问注册表。它现在在我的 .exe 中。在我这样做之前,我的应用程序启用了很好的运行时主题。那个主题是什么困扰我。它看起来像旧版本的 Windows。完全过时了。我知道这是因为我使用了那个 .manifest 文件,但我不知道在 .manifest 文件中添加/更改/删除什么来启用 Windows 主题并保持管理权限。我该怎么办?

这是在我的 .manifest 文件中:

<?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="My app"
     type="win32"/> 
    <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
            <application> 
                <!--This Id value indicates the application supports Windows Vista functionality -->
                <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
                <!--This Id value indicates the application supports Windows 7 functionality-->
                <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
                <!--This Id value indicates the application supports Windows 8 functionality-->
                <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
                <!--This Id value indicates the application supports Windows 8.1 functionality-->
                <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
            </application> 
    </compatibility>
    <!-- Identify the application security requirements. -->
    <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
        <security>
            <requestedPrivileges>
                <requestedExecutionLevel
                level="requireAdministrator"
                uiAccess="false"/>
            </requestedPrivileges>
       </security>
  </trustInfo>
</assembly>
4

1 回答 1

1

一个应用程序只能有 1 个清单,因此当您使用自定义清单时,您有责任指定您的应用程序需要清单的所有相关部分。因此,您需要添加启用 ComCtrl32 v6 的部分:

<?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="My app"
    type="win32"/> 
  <!-- enable Comctrl v6 for visual styles -->
  <dependency>
    <dependentAssembly>
      <assemblyIdentity
        type="win32"
        name="Microsoft.Windows.Common-Controls"
        version="6.0.0.0"
        processorArchitecture="*"
        publicKeyToken="6595b64144ccf1df"
        language="*"/>
    </dependentAssembly>
  </dependency>
  <compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1"> 
    <application> 
      <!--This Id value indicates the application supports Windows Vista functionality -->
      <supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/> 
      <!--This Id value indicates the application supports Windows 7 functionality-->
      <supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
      <!--This Id value indicates the application supports Windows 8 functionality-->
      <supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
      <!--This Id value indicates the application supports Windows 8.1 functionality-->
      <supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
    </application> 
  </compatibility>
  <!-- Identify the application security requirements. -->
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
    <security>
      <requestedPrivileges>
        <requestedExecutionLevel
          level="requireAdministrator"
          uiAccess="false"/>
      </requestedPrivileges>
    </security>
  </trustInfo>
</assembly>
于 2014-06-06T23:02:11.173 回答