Solutions for DLL files in the installation package that are not properly registered under WIN7

Source: Internet
Author: User

EXE under Vista or Win7 does not run under administrator rights, will be UAC (user Account Control) to prevent access to certain features of the system, such as modify the registry operation, etc., how to let EXE run with administrator rights, there are two methods, one is to modify the Exe property directly The other is to add manifest resources to the program, which are described separately below.

1. Modify the EXE properties directly:

1) Right-click on "EXE" and select "Properties" in the popup menu, such as:

2) Select the "Compatibility" entry and tick the "run this program as administrator" entry.

2. Add manifest resources in the program, divided into C # and Delphi implementation methods:

1) C #:

? Open Vs2005 or vs2008 project, see if there is app.manifest this file in the properties, if not, right click the project in the menu select "Properties", the interface appears as follows:

? Check "Security" and check "Enable ClickOnce Security Settings" in the interface to automatically generate the App.manifest file under properties.

Open a app.manifest file and join <security>

<requestedPrivileges>

<requestedexecutionlevel level= "Requireadministrator" cess= "false"/>

</requestedprivileges>, recompile,

The entire code looks like this:

<?xml version= "1.0" encoding= "Utf-8"?>

<asmv1:assembly manifestversion= "1.0" xmlns= "urn:schemas-microsoft-com:asm.v1" xmlns:asmv1= "urn: Schemas-microsoft-com:asm.v1 "xmlns:asmv2=" Urn:schemas-microsoft-com:asm.v2 "xmlns:xsi=" http://www.w3.org/2001/ Xmlschema-instance ">

<trustinfo xmlns= "Urn:schemas-microsoft-com:asm.v2" >

<security>

<applicationRequestMinimum>

<permissionset class= "System.Security.PermissionSet" version= "1" unrestricted= "true" id= "Custom" samesite= "Site" />

<defaultassemblyrequest permissionsetreference= "Custom"/>

</applicationRequestMinimum>

<requestedPrivileges>

<requestedexecutionlevel level= "Requireadministrator" uiaccess= "false"/>

</requestedPrivileges>

</security>

</trustInfo>

</asmv1:assembly>

2) Delphi:delphi program must embed manifest information inside the resource.

? First 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>

Save As Uac.manifest, where the files are arbitrary. Pay special attention to the red "requireadministrator", which indicates that the program requires an administrator (Administrator) to function properly.

? Then edit an RC file with the name Uac.rc as follows:

1 uac.manifest

which

1-Represents the resource number

24-The resource type is Rtmainifest

uac.manifest-file name in front of

? Compile the RC file with BRCC32 as the res file, as follows:

BRCC32 Uac.rc-fouac.res

? Add in the program

{$R Uac.res}

Let Delphi compile the time, the uac.res compiled into the exe file

? Put the file in Vista or Win7 to run, you will see the program icon shows the UAC Shield flag.

Solutions for DLL files in the installation package that are not properly registered under WIN7

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.