Solved

How to exe from an exe ?

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

Expert Comment

by:Grayl1
ID: 2821612
Hi

just use WinExec(PChar('C:\MyOtherApp.exe), SW_NORMAL); to execute your outher app...
0
How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

 

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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
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…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

17 Experts available now in Live!

Get 1:1 Help Now