Posted December 27, 200816 yr 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)
December 27, 200816 yr 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 thoughAnd you have to change 'setup.exe' to the exe you want to open ofc.
December 27, 200816 yr Author 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..?
December 27, 200816 yr Author Still no successthis is my sourceunit Unit1;interfaceuses 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; ShellExecuteAimplementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);beginShellExecuteA(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'
December 27, 200816 yr To use that function you have to declare the ShellAPI unit... usesWindows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,Dialogs, StdCtrls, ShellAPI; ...and delete the line 'ShellExecuteA' here: varForm1: TForm1;ShellExecuteAimplementation Now it should run...
Create an account or sign in to comment