The UAC mechanism provided by Windows 7 and Vista aims to prevent malicious modifications to the operating system itself.
The Influence of UAC on Delphi mainly lies in the following points:
1. Due to the UAC mechanism, Delphi may silently fail to operate the system, and the same program may run normally under 2000/X. For example, registry modification...
2. To avoid this situation, the Delphi program must support Vista UAC annotation, that is, the shield icon is displayed under the UAC Program icon. In this way, you can remind users when they need higher system permissions.
To enable the program to display the UAC flag, Vista now determines whether to display the "UAC shield" by reading the manifest resource in the resource of the program ".
To support UAC, the Delphi program must embed manifest information in the resource.
1. edit a file named UAC. manifest with the following content:
<? 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.
UAC manifest Option
<Requestedexecutionlevel level = "asinvoker" UIAccess = "false"/>
<Requestedexecutionlevel level = "requireadministrator" UIAccess = "false"/>
<Requestedexecutionlevel level = "highestavailable" UIAccess = "false"/>
2. Create an editing file named UAC. RC and add the following line:
1 24 UAC. manifest
Where:
1-resource ID
24-the resource type is rtmainifest
UAC. manifest-previous file name
3. Use brcc32 to compile the RC file as the res file.
Brcc32 UAC. RC-fouac. Res
Where-FO sets the output file name
4. Open the View Source menu item under the project menu or directly edit the project's DPR file, and then
{$ R *. Res}
Add a row below
{$ R uac. Res}
Or merge 3,4 into {$ R 'uac. res' UAC. RC '}
Re-compile the file so that UAC. Res can be compiled into the EXE file during Delphi compilation.
The UAC shield icon is displayed under the program icon.
5. Note that this program cannot run on the SUBST Virtual Drive. Otherwise, the system prompts "the specified path does not exist"
6. If an error occurs during compilation: deselect the check box before project> Options> Application> enable runtime themes, and then compile it!