Solved

Executing another Program

Posted on 2001-08-22
10
155 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
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!

 
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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

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…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

734 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