HEROiC Posted December 27, 2008 Posted December 27, 2008 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)
Killboy Posted December 27, 2008 Posted December 27, 2008 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.
HEROiC Posted December 27, 2008 Author Posted December 27, 2008 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..?
Killboy Posted December 27, 2008 Posted December 27, 2008 Okay, try:ShellExecuteA(0, 'Open', 'setup.exe', 0, 0, SW_SHOW);
HEROiC Posted December 27, 2008 Author Posted December 27, 2008 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'
Nacho_dj Posted December 27, 2008 Posted December 27, 2008 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...
HEROiC Posted December 27, 2008 Author Posted December 27, 2008 (edited) IT WORKS!, thnx guys .. Edited December 27, 2008 by HEROiC
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now