您的位置:首页 > 编程语言 > Delphi

Delphi下如何使程序在Win7/Vista上用管理员权限运行

2009-10-09 13:52 716 查看
操作步骤如下:

1.建立 res 文件

建立一个文本文件,名字可以自己起,我这里叫: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>

建立文本文件,名为 UAC.rc,内容:

1 24 UAC.manifest
编译成 uac.res 文件,运行:

brcc32 uac.rc -fouac.res
2.在代码中引入
打开项目文件,加入

{$R uac.res}
3.编译程序

这时程序就支持 Win7/VISTA 了,在运行的时候,会弹出 WINDOWS 的提示框,询问用户是否允许以管理员身份运行。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: