Delphi and Windows 7 User Account Control (UAC) mechanism (with a small shield), the Registry did not respond

Source: Internet
Author: User

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!

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.