Solved

How to exe from an exe ?

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

 

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

Suggested Solutions

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…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

733 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