WIN7, Vista提供的UAC机制,它的主要目的是防止对于操作系统本身的恶意修改。 对于Delphi程序的影响,UAC主要在于以下几点: 1、由于UAC机制,Delphi对于系统的操作可能无声的失败,而同样的程序,在2000/X下面可能运行正常。譬如注册表的改动。。。 2、为了避免这样的情况,Delphi程序必须支持Vista UAC标注,也就是说,在UAC程序的图标下面显示盾牌标志。这样可以在需要系统更高权限的时候,提醒用户。 为了让程序显示UAC标志,现在看来Vista/Windows 7是通过读取程序的资源(Resource)里面的MANIFEST资源,来决定是否显示“UAC盾牌”。 为了支持UAC,Delphi程序必须在资源里面嵌入MANIFEST信息。 1、首先编辑一个文件,内容如下: <?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <assemblyIdentity name="naily.pdbm.exe" processorArchitecture="x86" version="5.1.0.0" type="win32"/> <description>NAILY Soft</description> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="6595b64144ccf1df" language="*"/> </dependentAssembly> </dependency> <!-- Identify the application security requirements. --> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> </assembly> 保存为UAC.manifest 2、然后编辑一个RC文件,名为uac.rc 1 24 UAC.manifest 其中: 1-代表资源编号 24-资源类型为RTMAINIFEST UAC.manifest-前面的文件名称 3、用brcc32编译这个rc文件为res文件 brcc32 uac.rc -fouac.res 4、在程序里面加入 {$R uac.res} 让Delphi编译的时候,把uac.res编译进exe文件 5、程序图标下面显示UAC盾牌标志了。 PS:在编译时若产生错误:在project-application-enable runtime themes前面的勾取消,再编译就可以了。。。 |
|