创建一个文件UAC.manifest,内容如下:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0"> <dependency> <dependentAssembly> <assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/> </dependentAssembly> </dependency> <trustInfo xmlns="urn:schemas-microsoft-com:asm.v3"> <security> <requestedPrivileges> <requestedExecutionLevel level="requireAdministrator" uiAccess="false"/> </requestedPrivileges> </security> </trustInfo> </assembly>
如果是不同版本的Delphi,请参考Delphi安装目录\bin\default_app.manifest文件,将上文高亮行改成requireAdministrator即可。
然后,点击Delphi的Project菜单,Options,打开设置对话框,点击左侧的Application,在Runtime Themes中选择Use custom manifest,选择刚创建的文件即可。