请问有没有Delphi 7的清单文件示例,可以让应用程序在Windows XP / Vista / 7上以管理员身份运行?
使用此功能运行应用程序通常会导致一个用户帐户控制 (UAC) 对话框,要求特权权限。
请问有没有Delphi 7的清单文件示例,可以让应用程序在Windows XP / Vista / 7上以管理员身份运行?
使用此功能运行应用程序通常会导致一个用户帐户控制 (UAC) 对话框,要求特权权限。
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="App" version="3.1.0.0" processorArchitecture="*"/>
<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>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
</application>
</compatibility>
</assembly>
您可以添加更多项目到此清单中。您也可以删除Microsoft.Windows.Common-Controls
部分以禁用主题支持。
3. 将清单编译为资源:在项目目录中创建一个名为Win7UAC.rc
的文件,其中包含一行:
1 24 "Win7UAC.manifest"
为了编译这个文件,打开命令提示符(cmd),指向项目目录并运行以下命令:
brcc32.exe Win7UAC.rc
4. 将资源(清单)添加到项目中:只需在项目的任何一个单元文件中的任意位置添加以下行:
{$R 'Win7UAC.res'}
在项目主文件中(通常命名为Project1.dpr
)和{$R *.res}
行之后,添加这一行是一个合适的地方。
5. 重新编译项目
6. 记住,每当你向任何项目单元添加XPMan组件时,该UAC清单将无法正常工作。
以下是一些有用的链接
<?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="x86" />
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v2">
<security>
<requestedPrivileges>
<requestedExecutionLevel
level="highestAvailable"/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
XPMan
的使用。 - Isaac<?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="x86"
/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="highestAvailable" />
</requestedPrivileges>
</security>
</assembly>