操作步骤如下:
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 的提示框,询问用户是否允许以管理员身份运行。
本文介绍如何通过创建并编译特定的资源文件使应用程序支持Win7/VISTA的操作系统,并在运行时以管理员权限启动。具体步骤包括创建UAC.manifest文件,使用资源编译器生成res文件,然后在应用程序代码中引入该文件。
2783

被折叠的 条评论
为什么被折叠?



