Delphi与Windows 7下的用户账户控制(UAC)机制(有可能需要取消enable runtime themes)
2017-03-11 02:04
726 查看
WIN7/WIN8/WIN10, Vista提供的UAC机制,它的主要目的是防止对于操作系统本身的恶意修改。
对于Delphi程序的影响,UAC主要在于以下几点:
1、由于UAC机制,Delphi对于系统的操作可能无声的失败,而同样的程序,在2000/X下面可能运行正常。譬如注册表的改动。。。
2、为了避免这样的情况,Delphi程序必须支持Vista UAC标注,也就是说,在UAC程序的图标下面显示盾牌标志。这样可以在需要系统更高权限的时候,提醒用户。
为了让程序显示UAC标志,现在看来Vista是通过读取程序的资源(Resource)里面的MANIFEST资源,来决定是否显示“UAC盾牌”。
为了支持UAC,Delphi程序必须在资源里面嵌入MANIFEST信息。
1、首先编辑一个文件,内容如下:
[delphi] view plain copy
print?
<?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.manifest,这里文件是随意的。特别注意红色的“requireAdministrator”,这个表示程序需要管理员(Administrator)才能正常运行。
UAC Manifest 选项:
[delphi] view plain copy
print?
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
2、然后编辑一个RC文件,名为uac.rc
[delphi] view plain copy
print?
1 24 UAC.manifest
其中:<p>1-代表资源编号,24-资源类型为RTMAINIFEST,UAC.manifest-前面的文件名称
</p>
3、用brcc32编译这个rc文件为res文件
[delphi] view plain copy
print?
brcc32 uac.rc -fouac.res
其中 -fo 设置输出文件名
4、在Project程序里面加入:
[delphi] view plain copy
print?
{$R uac.res}
或者将3,4合并为:
{$R 'uac.res' 'uac.rc'},但是必须将uac.rc添加到项目中去。
让Delphi编译的时候,把uac.res编译进exe文件
程序图标下面显示UAC盾牌标志了。
5、注意,这个程序不能运行在subst 虚拟驱动器上,否则会提示“指定路径不存在”
6、在编译时若产生错误:在project->options->application->enable runtime themes前面的勾取消,再编译就可以了!
http://blog.csdn.net/zisongjia/article/details/68941974
对于Delphi程序的影响,UAC主要在于以下几点:
1、由于UAC机制,Delphi对于系统的操作可能无声的失败,而同样的程序,在2000/X下面可能运行正常。譬如注册表的改动。。。
2、为了避免这样的情况,Delphi程序必须支持Vista UAC标注,也就是说,在UAC程序的图标下面显示盾牌标志。这样可以在需要系统更高权限的时候,提醒用户。
为了让程序显示UAC标志,现在看来Vista是通过读取程序的资源(Resource)里面的MANIFEST资源,来决定是否显示“UAC盾牌”。
为了支持UAC,Delphi程序必须在资源里面嵌入MANIFEST信息。
1、首先编辑一个文件,内容如下:
[delphi] view plain copy
print?
<?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.manifest,这里文件是随意的。特别注意红色的“requireAdministrator”,这个表示程序需要管理员(Administrator)才能正常运行。
UAC Manifest 选项:
[delphi] view plain copy
print?
<requestedExecutionLevel level="asInvoker" uiAccess="false" />
<requestedExecutionLevel level="requireAdministrator" uiAccess="false" />
<requestedExecutionLevel level="highestAvailable" uiAccess="false" />
2、然后编辑一个RC文件,名为uac.rc
[delphi] view plain copy
print?
1 24 UAC.manifest
其中:<p>1-代表资源编号,24-资源类型为RTMAINIFEST,UAC.manifest-前面的文件名称
</p>
3、用brcc32编译这个rc文件为res文件
[delphi] view plain copy
print?
brcc32 uac.rc -fouac.res
其中 -fo 设置输出文件名
4、在Project程序里面加入:
[delphi] view plain copy
print?
{$R uac.res}
或者将3,4合并为:
{$R 'uac.res' 'uac.rc'},但是必须将uac.rc添加到项目中去。
让Delphi编译的时候,把uac.res编译进exe文件
程序图标下面显示UAC盾牌标志了。
5、注意,这个程序不能运行在subst 虚拟驱动器上,否则会提示“指定路径不存在”
6、在编译时若产生错误:在project->options->application->enable runtime themes前面的勾取消,再编译就可以了!
http://blog.csdn.net/zisongjia/article/details/68941974
相关文章推荐
- Delphi与Windows 7下的用户账户控制(UAC)机制(加小盾牌),注册表没反应
- Delphi与Windows 7下的用户账户控制(UAC)机制(加小盾牌),注册表没反应
- Delphi与Windows 7下的用户账户控制(UAC)机制
- Delphi与Windows 7下的用户账户控制(UAC)机制 及 禁用兼容性助手
- Delphi与Windows 7下的用户账户控制(UAC)机制
- Delphi与Windows 7下的用户账户控制(UAC)机制
- Delphi与Windows 7下的用户账户控制(UAC)机制
- 如何在Windows 8 中关闭用户账户控制(UAC)
- win7系统取消用户账户控制(UAC)免受提示窗的打扰
- win7系统:用户账户控制如何取消掉
- Windows Vista for Developers——第四部分:用户帐号控制(User Account Control,UAC)
- windows8中怎么关闭用户账户控制(UAC)仅针对单个用户
- Windows Vista for Developers——第四部分:用户帐号控制(User Account Control,UAC)
- Windows Vista for Developers——第四部分:用户帐号控制(User Account Control,UAC)
- Windows XP用户账户空白(控制面版里用户账户空白)
- Inside windows vista User Account Control 用户账户控制
- Windows 8系统默认开启的.Net Framework版本是4.0,而部分用户可能需要使用到3.5或以下版本,简单添加方法
- 用户“XXX\XXX”不具有所需的权限。请验证授予了足够的权限并且解决了 Windows 用户帐户控制(UAC)限制问题。
- Windows Vista User Account Control (UAC) 全新安全模块“用户帐户控制”
- Windows Vista User Account Control (UAC) 全新安全模块“用户帐户控制”