Solved

How to exe from an exe ?

Posted on 2000-05-17
8
133 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
  • 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
ScreenConnect 6.0 Free Trial

At ScreenConnect, partner feedback doesn't fall on deaf ears. We collected partner suggestions off of their virtual wish list and transformed them into one game-changing release: ScreenConnect 6.0. Explore all of the extras and enhancements for yourself!

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

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…
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

770 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