Solved

Executing another Program

Posted on 2001-08-22
10
154 Views
Last Modified: 2010-04-06
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
Comment
Question by:neopolis
  • 4
  • 4
  • 2
10 Comments
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6412604
uses shellapi;

procedure TForm1.Button1Click(Sender: TObject);
begin
  shellexecute(Handle,'open',pchar('Happyface.exe'),nil,nil,sw_ShowNormal);
end;
0
 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6412609
sorry just change the exe file to contain the path like

pchar('c:\Happyface.exe')
0
 

Author Comment

by:neopolis
ID: 6412690
I get undeclared identifier: 'Handle'
0
Industry Leaders: 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!

 
LVL 22

Expert Comment

by:Mohammed Nasman
ID: 6412703
try
  Form1.Handle

or any form you are using

which version of delphi u r using?
0
 

Author Comment

by:neopolis
ID: 6412733
I get undeclared identifier: 'Handle'
0
 
LVL 22

Accepted Solution

by:
Mohammed Nasman earned 10 total points
ID: 6412737
try using WinExec, but this function is provided for compatibility with earlier versions of Windows.
WinExec(pchar('c:\Happyface.exe'),sw_ShowNormal)
0
 

Author Comment

by:neopolis
ID: 6412740
the program i am writing does not have forms or buttons
its a dll i am using Delphi 5
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 6412866
Maybe you can use FileExecute() :
Example : FileExecute('NotePad',strFileName,strFilePath,esNormal);

Best regards,
The Mayor
0
 

Author Comment

by:neopolis
ID: 6412868
thanks the WinExec works for me i am win 98
thanks
0
 
LVL 6

Expert Comment

by:wimmeyvaert
ID: 6412873
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

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Delphi Firemonkey Need Sample for Online Shopping Example. 2 191
Delphi: Connect to running MS Outlook 4 157
DBCtrlGrid, Delphi, Scroll 7 32
Delphi, TImage, Png 2 19
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Although Jacob Bernoulli (1654-1705) has been credited as the creator of "Binomial Distribution Table", Gottfried Leibniz (1646-1716) did his dissertation on the subject in 1666; Leibniz you may recall is the co-inventor of "Calculus" and beat Isaac…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

740 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question