6
I’m using Delphi XE4 and have no idea how to get an application to ask administrative permission for Windows 7 to run, I searched websites and bolgs, but I couldn’t find the answer! Help me please!
6
I’m using Delphi XE4 and have no idea how to get an application to ask administrative permission for Windows 7 to run, I searched websites and bolgs, but I couldn’t find the answer! Help me please!
7
First you should create a text 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">
<assemblyIdentity type="win32" name="Teste" version="3.1.0.0" processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows 8 Support -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
</assembly>
Save with the name "Manifest.manifest" inside the folder of your project (I recommend that you create a subfolder called "Resources", to place these files).
After that create another text file, with the following content:
1 24 "Manifest.manifest"
Save this other file with the name Manifest.rc, in the same folder where you saved the file "Manifest.manifest" above.
Then after that Compile this file using the following command line (or create a BAT for it):
BRCC32.exe Manifest.rc
A file called Manifest will be automatically created.res
Then, lastly, add the following line to your code:
{$R 'Manifest.res'}
This way, when opening the executable, if the Windows UAC is enabled, the privilege upgrade will be required.
I hope I helped! Good luck!
3
To do this you will need to create a Manifest customized.
Tip: To learn more about Manifest customized you can give a look at this link from Embarcadero: Customizing the Windows Application Manifest File
YOU CAN USE THIS FILE HERE
If you prefer you can use this ready aquivo, just do the following:
Contents of the manifest
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="Teste" version="3.1.0.0" processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--The ID below indicates application support for Windows Vista -->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--The ID below indicates application support for Windows 7 -->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows 8 Support -->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
</application>
</compatibility>
</assembly>
USING THE MANIFEST IN YOUR PROJECT
Follow the steps below:
IMPORTANT: With the Manifest you should realize that by pressing F9 to run your application in mode debug Delphi will not be able to run its application, the solution to this is to close the Delphi IDE and open it again with the option Run as administrator
IMAGES THAT ILLUSTRATE THE STEPS I INDICATED
Steps 1 to 4
Step 5
Step 6
-2
I added versions of windows in XML, in case someone needs:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity type="win32" name="NOME DO APLICATIVO COM A EXTESÃO (.EXE)" version="3.1.0.0" processorArchitecture="*"/>
<dependency>
<dependentAssembly>
<assemblyIdentity type="win32" name="Microsoft.Windows.Common-Controls" version="6.0.0.0" publicKeyToken="6595b64144ccf1df" language="*" processorArchitecture="*"/>
</dependentAssembly>
</dependency>
<trustInfo xmlns="urn:schemas-microsoft-com:asm.v3">
<security>
<requestedPrivileges>
<requestedExecutionLevel level="requireAdministrator" uiAccess="false"/>
</requestedPrivileges>
</security>
</trustInfo>
<compatibility xmlns="urn:schemas-microsoft-com:compatibility.v1">
<application>
<!--Windows Vista/6.0/Server 2008-->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
<!--Windows 7/6.1/Server 2008 R2-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows 8/6.2/Server 2012-->
<supportedOS Id="{4a2f28e3-53b9-4441-ba9c-d69d4a4a6e38}"/>
<!--Windows 8.1/6.3/Server 2012 R2-->
<supportedOS Id="{1f676c76-80e1-4239-95bb-83d0f6d0da78}"/>
<!--Windows 10/10.*-->
<supportedOS Id="{8e0f7a12-bfb3-4fe8-b9a5-48fd50a15a9a}"/>
</application>
</compatibility>
</assembly>
Browser other questions tagged delphi delphi-xe3 delphi-xe5 delphi-xe6 delphi-xe4
You are not signed in. Login or sign up in order to post.
It is necessary to use a manifest, more information on Delphi and Windows Vista User Account Control.
– stderr