Delphi 下如何使程序在 Win7/Vista 上用管理员权限运行
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 的提示框,询问用户是否允许以管 理员身份运行.