Address: http://clacklin.blog.163.com/blog/static/103209820106108538269/
Open the Vs2005 or vs2008 project and check whether the app. manifest file exists in Properties. If not, right-click the project and choose "Properties" from the menu ",
Select "security" and select "enable ClickOnce Security Settings" on the interface. The app. manifest file is automatically generated under Properties.
Open the app. manifest file and add
<RequestedPrivileges>
<RequestedExecutionLevel level = "requireAdministrator" cess = "false"/>
</RequestedPrivileges>, recompile,
The Code is as follows:
<Xml version = "1.0" encoding = "UTF-8">
<Asmv1: assembly manifestVersion = "1.0" xmlns = "urn: schemas-microsoft-com: asm. v1 "xmlns: asmv1 =" urn: schemas-microsoft-com: asm. v1 "xmlns: asmv2 =" urn: schemas-microsoft-com: asm. v2 "xmlns: xsi =" http://www.w3.org/2001/XMLSchema-instance ">
<TrustInfo xmlns = "urn: schemas-microsoft-com: asm. v2">
<Security>
<ApplicationRequestMinimum>
<PermissionSet class = "System. Security. PermissionSet" version = "1" Unrestricted = "true" ID = "Custom" SameSite = "site"/>
<DefaultAssemblyRequest permissionSetReference = "Custom"/>
</ApplicationRequestMinimum>
<RequestedPrivileges>
<RequestedExecutionLevel level = "requireAdministrator" uiAccess = "false"/>
</RequestedPrivileges>
</Security>
</TrustInfo>
</Asmv1: assembly>
2) Delphi: the Delphi program must embed MANIFEST information in the resource.
Edit an object as follows:
<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>
Save as UAC. manifest. The file is random here. Pay special attention to the red "requireAdministrator", which indicates that the program must run properly as Administrator.
Edit an RC file named uac. rc as follows:
1 24 UAC. manifest
Where:
1-resource ID
24-the resource type is RTMAINIFEST
UAC. manifest-previous file name
Use brcc32 to compile this rc file as the res file, as shown below:
Brcc32 uac. rc-fouac. res
Add in the program
{$ R uac. res}
Compile uac. res into the exe file during Delphi compilation.
Put the file in vista or win7 and run it. The UAC shield icon is displayed under the program icon.