windows7以上操作系统,Delphi程序自动获得管理员权限运行

Q:开发环境,win8 +delphi xe 10.3.1 ,想让程序用管理员权限运行。
1)根据菜单设置: project/options/application/manifest
execution level 选择了require administrator后,运行程序还是没有用administra
tor权限运行啊。
2)用网上说的UAC.manifest 编译出UAC.res ,在工程文件中 {$R UAC.res},也不行。

请问各位高手大侠,应该怎么办才行呢?

A:谢谢各位大侠的帮助。经过查资料,各种研究和尝试,弄出来了小盾牌了。下面分享给需要的小伙伴。
整个过程如下。

UAC.manifest文件内容如下
<?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>

1)把UAC.manifest文件保存到项目根目录。
2)project-》options-》application-》manifest  manifest file 那个下拉框选择custom, 最下面的 custom manifest 选择 UAC.manifest
3)clean build all,
4)检查一下程序图标,已经带有小盾牌了。

不用在用bcc32 编译了。只需要一个manifest文件。delphi真的很伟大很方便。

----------------------------------------------欢迎加入Delphi知识局QQ群:32422310-----------------------------------

原帖来自Delphi盒子:http://bbs.2ccc.com/topic.asp?topicid=567941

发布了58 篇原创文章 · 获赞 10 · 访问量 4万+

猜你喜欢

转载自blog.csdn.net/xyzhan/article/details/97885454