How to run a program with administrator privileges on Windows 7/Vista in Delphi

Source: Internet
Author: User

The procedure is as follows:

1. Create a res File

Create a text file named by yourself. Here is UAC. manifest. 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>

Create a text file named UAC. Rc. content:

1 24 UAC. manifest
Compile it into the UAC. Res file and run:

Brcc32 UAC. RC-fouac. Res
2. InCodeIntroduced in
Open the project file and add

{$ R uac. Res}
3. CompileProgram

In this case, the program supports win7/Vista. When running, a Windows Prompt box is displayed asking whether the user is allowed to run as an administrator.

Related Article

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.