If you are still creating Delphi 7 applications, then you may have had problems with UAC in Windows Vista, 7 and 2008, your application launches but is unable to eg. access the HKEY-LOCAL-MACHINE hive of the registry, what you need is to have the application launch with Administrative rights.
You could just rightclick on the application icon and choose “Run as administrator” however this is hardly professional for a program you distribute to others.
Well, it took a bit of Googling and a bit of experimenting, but here’s the recipe to creating UAC aware applications in Delphi 7.
- First, create a new application and save the project.
In the project directory you just created create 2 files;
. - The first file “UAC.MANIFEST” should look like this;
—————————————————————————–
<?xml version=”1.0″ encoding=”UTF-8″ standalone=”yes”?>
<assembly xmlns=”urn:schemas-microsoft-com:asm.v1″ manifestVersion=”1.0″>
<assemblyIdentity version=”1.0.0.0″ processorArchitecture=”*” name=”UACAwareApplication” type=”win32″/>
<trustInfo xmlns=”urn:schemas-microsoft-com:asm.v3″>
<security>
<requestedPrivileges>
<requestedExecutionLevel level=”requireAdministrator”/>
</requestedPrivileges>
</security>
</trustInfo>
</assembly>
—————————————————————————–
. - Second file “vistaprog.rc” should look like this;
—————————————————————————–
1 24 uac.manifest
—————————————————————————–
(yes it’s only one line)
. - Now you need to compile the “vistaprog.rc” file.
you do this by running the “brcc32.exe” (found in the Delphi Bin directory) with this parameter “brcc32.exe vistaprog.rc“, this will compile a “vistaprog.res” file (this is a bit different/easier on Delphi 2007 etc, see links at the bottom for more details).
. - Now you will need to modify your Delphi project.
In the “unit1.pas” file find {$R *.dfm} and insert {$R ‘vistaprog.res’} just below it, save the project and compile it.
You application is now Vista/Windows 7/2008 UAC aware, you will also notice that a small shield is added to the application icon.
When you run your application it will look aimilar to this;
Read more here;
http://www.zhou73.cn/index.php/article/zhou73/2009-02-18/195.html
http://www.zhou73.cn/index.php/article/zhou73/2009-02-18/196.html
http://ruminatedrumblings.blogspot.com/2008/03/vista-uac-manifest.html
http://www.experts-exchange.com/Programming/Languages/Pascal/Delphi/Q_22755023.html
Hi, there occourse an Error Dialog on Win7
“Unable to create Process” talking about side-to-side configuration problems.