我的程序应该以管理员身份运行。两年前,我创建了一个清单文件,它工作正常。但是现在,我从Delphi 2010转移到Delphi XE3并且它不起作用 - 程序像往常一样启动(而不是管理员)。此外,我将我的程序称为“MyApp”。
在源代码中,我声明了两个res文件:
{$R MyApp.res}
{$R Manifest.res}
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>
当我从源清单工作中删除{$ R MyApp.res}时。所以我理解MyApp.res(由Delphi自动生成)击败了Manifest.res。但在Delphi 2010中,此配置工作正常,但在XE3中不起作用。为什么?我怎么解决它?
答案 0 :(得分:9)
如果要为清单使用自定义.res文件,则需要禁用Delphi的默认清单,因为进程只能有1个清单。进入项目选项,在&#34;应用程序&#34;部分,并设置&#34;运行时主题&#34;选项&#34;无&#34;。
或者,将您的清单移动到.manifest文件中,然后设置&#34;运行时主题&#34;选项&#34;使用自定义清单&#34;。然后从代码中删除自定义.res文件。