Vista之家(www.vista123.com):Delphi下如何使程序在Vista上用管理员权限运行
刚才在这篇文章:在VC中添加资源文件,使程序在Vista上用管理员权限运行 里面提到了VC++搞定程序自动申请管理员权限执行的解决方案,那么,Delphi下面又如何实现的呢,刚才有朋友在QQ群里面问到了这个问题,就顺便贴出来一下吧,毕竟Win32程序的开发,Delphi还是有顽强的生命力的。
操作步骤如下:
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.编译程序
这时程序就支持 VISTA 了,在运行的时候,会弹出 WINDOWS 的提示框,询问用户是否允许以管理员身份运行。
Vista之家(www.vista123.com),爱上网,爱上Vista123.com
|
热门文章
| ||


English





