Jump to content
Tuts 4 You

Question..


HEROiC

Recommended Posts

Posted

Hello,

Im making a program that will load an setup file for example:

I fire up my delphi project and i got a installer.exe now how do i execute it (if i press on Button in Delphi)

Posted

Not sure how Windows API integration works in Delphi, but it should be done like this:

ShellExecute(Window, 'Open', 'setup.exe', 0, 0, SW_SHOW);

where Window is the handle to your window (duh), you can set it to 0 though

And you have to change 'setup.exe' to the exe you want to open ofc.

Posted

If i try to run it i get these errors:

Build

[Error] Unit1.pas(29): Undeclared identifier: 'ShellExecute'

[Error] Unit1.pas(29): Undeclared identifier: 'Window'

[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

so what to do next..?

Posted

Okay, try:

ShellExecuteA(0, 'Open', 'setup.exe', 0, 0, SW_SHOW);
Posted

Still no success

this is my source

unit Unit1;

interface

uses

Windows, Messages, SysUtils, Variants, 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;

ShellExecuteA

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);

begin

ShellExecuteA(0, 'Open', 'setup.exe', 0, 0, SW_SHOW);

end;

end.

and this is the error it gave me if i try to run it:

Build

[Error] Unit1.pas(22): ',' or ':' expected but 'IMPLEMENTATION' found

[Fatal Error] Project1.dpr(5): Could not compile used unit 'Unit1.pas'

Posted

To use that function you have to declare the ShellAPI unit...

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ShellAPI;

...and delete the line 'ShellExecuteA' here:

var
Form1: TForm1;
ShellExecuteA
implementation

Now it should run... :)

Posted (edited)

IT WORKS!, thnx guys .. :)

Edited by HEROiC

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...