Solved

How to exe from an exe ?

Posted on 2000-05-17
8
138 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

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!

Question has a verified solution.

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

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
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: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
If you’ve ever visited a web page and noticed a cool font that you really liked the look of, but couldn’t figure out which font it was so that you could use it for your own work, then this video is for you! In this Micro Tutorial, you'll learn yo…

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