• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 165
  • Last Modified:

Executing another Program

Hello
i want to execute another program from a command or procedure from my Delphi Program..


Example how do i start a program called  Happyface.exe
its in C:\

thanks in advance neopolis
0
neopolis
Asked:
neopolis
  • 4
  • 4
  • 2
1 Solution
 
Mohammed NasmanSoftware DeveloperCommented:
uses shellapi;

procedure TForm1.Button1Click(Sender: TObject);
begin
  shellexecute(Handle,'open',pchar('Happyface.exe'),nil,nil,sw_ShowNormal);
end;
0
 
Mohammed NasmanSoftware DeveloperCommented:
sorry just change the exe file to contain the path like

pchar('c:\Happyface.exe')
0
 
neopolisAuthor Commented:
I get undeclared identifier: 'Handle'
0
Cloud Class® Course: Microsoft Azure 2017

Azure has a changed a lot since it was originally introduce by adding new services and features. Do you know everything you need to about Azure? This course will teach you about the Azure App Service, monitoring and application insights, DevOps, and Team Services.

 
Mohammed NasmanSoftware DeveloperCommented:
try
  Form1.Handle

or any form you are using

which version of delphi u r using?
0
 
neopolisAuthor Commented:
I get undeclared identifier: 'Handle'
0
 
Mohammed NasmanSoftware DeveloperCommented:
try using WinExec, but this function is provided for compatibility with earlier versions of Windows.
WinExec(pchar('c:\Happyface.exe'),sw_ShowNormal)
0
 
neopolisAuthor Commented:
the program i am writing does not have forms or buttons
its a dll i am using Delphi 5
0
 
wimmeyvaertCommented:
Maybe you can use FileExecute() :
Example : FileExecute('NotePad',strFileName,strFilePath,esNormal);

Best regards,
The Mayor
0
 
neopolisAuthor Commented:
thanks the WinExec works for me i am win 98
thanks
0
 
wimmeyvaertCommented:
Oops,
forgot to mention that this is a function which comes with the RxLib, and that you have to declare RxShell in the Uses-Clause.

Maybe after all, this is not what you are looking for.

The Mayor
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 4
  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now