I'm using Delphi 5 running on Windows 7. An old application we want to update now has issues with UAC. We are able to get around it by changing the EnableLUA setting in the registry, but that's NOT an ideal solution. I'm trying to elevate it and found a lot of information online about how to do so. Before messing with the program, I created a very simple new program called InstallTester to use to figure out the process I need to use to fix this. Then I created a manifest called InstallTester.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="InstallTester" version="1.0.0.0" processorArchitecture="x86"/>
<dependency>
<dependentAssembly>
<assemblyIdentity
type="win32"
name="Microsoft.Windows.Common-Controls"
version="6.0.0.0"
publicKeyToken="6595b64144ccf1df"
language="*"
processorArchitecture="*"/>
</dependentAssembly>
</dependency>
<!-- Windows Vista application security requirements. -->
<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 7-->
<supportedOS Id="{35138b9a-5d96-4fbd-8e2d-a2440225f93a}"/>
<!--Windows Vista-->
<supportedOS Id="{e2011457-1546-43c5-a5fe-008deee3d3f0}"/>
</application>
</compatibility>
</assembly>
Then I created the .rc file (called Carrie.rc; at first I tried to call it InstallTester.rc, but I got a Duplicate Resources error, so I changed it) to include the manifest:
1 24 "InstallTester.manifest"
Then I compiled the .rc file using brcc32.exe, which created a .res file. Then I added the line to include the .res file in the app.dpr:
{$R 'Carrie.res'}
Then I built the project. And now when I run it (outside the IDE; inside the IDE I get the error saying it requires elevation), I don't get a Windows window asking if I give any permission. Instead I get the application, plus a window that looks like a command prompt window, but without any text. It has a cursor, but I can't type anything in it:
Just in case it's helpful, here's the full code:
program InstallTester;
{$R *.res}
{$R 'Carrie.res'}
uses
Forms,
InstallTest in 'InstallTest.pas' {Form1};
begin
Application.Initialize;
Application.CreateForm(TForm1, Form1);
Application.Run;
end.
unit InstallTest;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
begin
MessageDlg( 'Thanks!', mtInformation, [mbOK], 000 );
end;
end.
Does anyone have a solution?