Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Call *.exe in delphi

Status
Not open for further replies.

panadoll

Programmer
Feb 28, 2002
52
SG
Hi,

I am new to Delphi. I am currently using Delphi 7.
Right now, I want to execute a *.exe from delpbi application. How should I do that? Thanks
 
You can for example use do this way..

uses ShellAPI;

procedure TForm1.Button1Click(Sender: TObject);
begin
ShellExecute(Self.Handle, 'Open', 'C:\MyExe.exe', '', '', SW_SHOW);
end;

 
Hi, Thanks for your reply

I have tried out your solution. However, there are 2 error message which i do not understand.

"[Error] DeployBDE.dpr(68): Undeclared identifier: 'Self'" and
"[Error] DeployBDE.dpr(68): 'END' expected but ',' found"

Can you please help me?
 
I use something like this

Code:
label1.caption := 'C:\WINNT\welcome.exe';
winexec(pchar(label1.caption), sw_show);

Can also be done with just one line...

Code:
winexec('C:\WINNT\welcome.exe', sw_show);

But I find it more usefull to be able to change which file is run at run time.

Hope that helps,
JW.
 
Or use the much simpler function 'Executefile' provided by Borland, its in Demos/doc/filmanex/fmxutils.pas
just include fmxutils in your project.
e.g Executefile('mypath/myfile.exe','','',SW_SHOW);

Steve.
 
Could you show me the code where the error occurs. I believe you forgot some 'tags' or 'ends' in the code.

I also think that JustinWillis method is better since you can change file at run-time.

sggaunt method is also allright to use...

I hope it helps..

Michael
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top