不要捕获清单文件

m1k*_*now 5 delphi uac

我的程序应以管理员身份运行.两年前,我创建了一个清单文件,它工作正常.但是现在,我从Delphi 2010转移到Delphi XE3并且它不起作用 - 程序像往常一样启动(而不是管理员).此外,我将我的程序称为"MyApp".

在源代码中,我声明了两个res文件:

{$R MyApp.res}
{$R Manifest.res}
Run Code Online (Sandbox Code Playgroud)

Manifest是由以下代码创建的:

<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> 
  <assemblyIdentity 
    type="win32" 
    name="MyApp" 
    version="1.1.0.0" 
    processorArchitecture="x86"/> 
  <description> 
    MyApp 
  </description> 
  <dependency> 
    <dependentAssembly> 
      <assemblyIdentity 
        type="win32" 
        name="Microsoft.Windows.Common-Controls" 
        version="6.0.0.0" 
        publicKeyToken="*deleted*" 
        language="*" 
        processorArchitecture="x86"/> 
    </dependentAssembly> 
  </dependency> 
  <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> 
    <security> 
      <requestedPrivileges> 
        <requestedExecutionLevel 
          level="requireAdministrator" 
          uiAccess="false"/> 
        </requestedPrivileges> 
    </security> 
  </trustInfo> 
</assembly>
Run Code Online (Sandbox Code Playgroud)

当我从源清单工作中删除{$ R MyApp.res}时.所以我理解MyApp.res(由Delphi自动生成)击败了Manifest.res.但在Delphi 2010中,此配置工作正常,但在XE3中不起作用.为什么?我怎么解决它?

Rem*_*eau 9

如果要为清单使用自定义.res文件,则需要禁用Delphi的默认清单,因为进程只能有1个清单.进入"应用程序"部分的"项目选项",并将"运行时主题"选项设置为"无".

或者,将清单移动到.manifest文件中,然后将"运行时主题"选项设置为"使用自定义清单".然后从代码中删除自定义.res文件.