Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 161
  • 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
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

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

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