Solved

Executing another Program

Posted on 2001-08-22
10
150 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:mnasman
Comment Utility
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:mnasman
Comment Utility
sorry just change the exe file to contain the path like

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

Author Comment

by:neopolis
Comment Utility
I get undeclared identifier: 'Handle'
0
 
LVL 22

Expert Comment

by:mnasman
Comment Utility
try
  Form1.Handle

or any form you are using

which version of delphi u r using?
0
 

Author Comment

by:neopolis
Comment Utility
I get undeclared identifier: 'Handle'
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 22

Accepted Solution

by:
mnasman earned 10 total points
Comment Utility
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
Comment Utility
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
Comment Utility
Maybe you can use FileExecute() :
Example : FileExecute('NotePad',strFileName,strFilePath,esNormal);

Best regards,
The Mayor
0
 

Author Comment

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

Expert Comment

by:wimmeyvaert
Comment Utility
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

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

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…
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

771 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

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now