Delphi supports the UAC mechanism of Vista

Source: Internet
Author: User

The UAC mechanism provided by Vista is one of the new features of Vista. Its main purpose is to prevent malicious modifications to the operating system itself. If you want to modify the system settings of Vista, you must pass UAC verification. This method greatly provides system security.

Regarding the advantages and disadvantages of UAC, the opinions on the network are mixed. We will not discuss them here.

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 Vista, the Delphi program must embed manifest information in the resource.

1. edit a file 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>

Keep it 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.

2. Edit an RC file named UAC. RC.

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 // Note: brcc32.exe is in the delphix \ bin directory.

4. Add in the program

{$ R uac. Res}

Compile UAC. Res into the EXE file during Delphi compilation.

5. Put the file in Vista and run it. The UAC shield icon is displayed under the program icon.

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.