Delphi Xe2 后的版本如何让Delphi程序启动自动“以管理员身份运行"

 由于Vista以后win中加入的UAC安全机制,采用Delphi开发的程序如果不右键点击“以管理员身份运行”,则会报错。

在XE2以上的Delphi版本处理这个问题已经非常简单了。

右建点击工程,选择“Options”->“Applicaion”下,将Runtime themes项设置为“Use Custom manifest”,点击下方按钮,选择相应的Manifest文件即可。

需要注意的是:Debug和Release模式不同,要进行同样设置

如图:

至于Manifest文件,也就是一个XML文档,原文如下:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>

原文地址:https://www.cnblogs.com/zhenfei/p/4478713.html