Delphi supports Vista's UAC mechanism

Source: Internet
Author: User
Tags new features resource xmlns

Vista provides a UAC mechanism that is one of the new features of Vista. Its primary purpose is to prevent malicious modifications to the operating system itself. If you want to make changes to Vista's system settings, you must pass the validation of UAC to be able to do so. By such means, the security of the system is greatly provided.

On the pros and cons of UAC, the network on the argument is mixed, here is not specifically discussed.

For the effect of Delphi program, UAC mainly lies in the following points:

1, due to the UAC mechanism, Delphi for the operation of the system may be silent failure, and the same program, under the 2000/x may run normally. For example, registry changes ...

2, in order to avoid such a situation, the Delphi program must support the Vista UAC callout, that is, the UAC program under the icon Display Shield logo. This allows users to be alerted when the system has higher privileges.

In order for the program to display the UAC flag, it now appears that Vista is using the manifest resource in the program's resources (Resource) to decide whether to display the UAC shield.

In order to support the VISTA,DELPHI program must embed manifest information inside the resource.

1, first edit a file, the contents are 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>

Keep it as uac.manifest, the file here is random. Pay special attention to the red "requireadministrator", which requires an administrator to function properly.

2, and then edit an RC file, called Uac.rc

1 24 UAC.manifest

which

1-On behalf of the resource number

24-Resource type is Rtmainifest

uac.manifest-Previous file name

3. Compile this rc file as res file with BRCC32

BRCC32 uac.rc-fouac.res//Note: Brcc32.exe in Delphix\bin directory

4, in the program to join

{$R uac.res}

Let Delphi compile the time, the uac.res into EXE file

5, put the file into Vista run, you will see the program icon below the UAC Shield logo is shown

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.