Solved

How to exe from an exe ?

Posted on 2000-05-17
8
139 Views
Last Modified: 2010-04-04
I have written two applications in Delphi 5.0 and I need to have one of them launching the other if certain conditions are met inside the program. How can I do this?

Thanks a lot in advance !!!
0
Comment
Question by:ajgonzalezm
[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
  • 3
  • 2
  • 2
  • +1
8 Comments
 
LVL 17

Accepted Solution

by:
inthe earned 50 total points
ID: 2819579
Hi,
uses shellapi;

on a button click event or whatever do

begin
if
// conditions_are_met
 then
ShellExecute(Handle,'open','c:\notepad.exe',nil,nil,SW_SHOWNORMAL)
else
//do nothing
end;

Regards Barry
0
 
LVL 17

Expert Comment

by:inthe
ID: 2819580
ps.
 need more details just ask ..
cheers
0
 
LVL 2

Expert Comment

by:mahara
ID: 2819586
hello,

you should use code below. this code executes your app. SW_Shownormal is the parameter about your app. window.

Well you could use ShellExecute or CreateProcess methods for special situations (i.e. you should create a process if you want to have control on the execution of the program you've ran - even find if it's continuing or when it ends etc) but winexec is cool if it's enough, because it's practical.

cheers !!!

/////////////////////////
var
apppath:string
success:boolean;

   apppath:='c:\myotherapp.exe';

   if fileexists(apppath) then
      begin
        success:=WinExec(PChar(dosya),  SW_SHOWNORMAL);
        if (success<>0) and (success<>ERROR_BAD_FORMAT) and (success<>ERROR_FILE_NOT_FOUND) and                         (success<>ERROR_PATH_NOT_FOUND) then
          begin
            // ok, my app did execute
          end
        else
          begin
            if success=0 then
               Showmessage('')
            else
               Showmessage('error= '+inttostr(int64(success)));
          end;
      end //if filexistz
   else
      Showmessage('apppath is not valid');

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!

 

Expert Comment

by:Grayl1
ID: 2821612
Hi

just use WinExec(PChar('C:\MyOtherApp.exe), SW_NORMAL); to execute your outher app...
0
 

Expert Comment

by:Grayl1
ID: 2821632
sorry...

WinExec(PChar('C:\MyOtherApp.exe'), SW_NORMAL); should it be...
0
 
LVL 2

Expert Comment

by:mahara
ID: 2822467
well, everyone has an answer, no? sorry because there's a small mistake in mine: the "dosya" is to be "apppath"

0
 
LVL 17

Expert Comment

by:inthe
ID: 2824551
hehe
 theres also createprocess() and its variants ...
0
 

Author Comment

by:ajgonzalezm
ID: 2829374
Thanks a lot inthe. Your solution worked very fine.

Regards,


AJ
0

Featured Post

VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

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

In this tutorial I will show you how to use the Windows Speech API in Delphi. I will only cover basic functions such as text to speech and controlling the speed of the speech. SAPI Installation First you need to install the SAPI type library, th…
Introduction I have seen many questions in this Delphi topic area where queries in threads are needed or suggested. I know bumped into a similar need. This article will address some of the concepts when dealing with a multithreaded delphi database…
Monitoring a network: how to monitor network services and why? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the philosophy behind service monitoring and why a handshake validation is critical in network monitoring. Software utilized …
Visualize your data even better in Access queries. Given a date and a value, this lesson shows how to compare that value with the previous value, calculate the difference, and display a circle if the value is the same, an up triangle if it increased…
Suggested Courses
Course of the Month10 days, 1 hour left to enroll

624 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