How to run an application in delphi?

I want to know how to run one application(.exe file) in another application?
dingchengAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

MadshiCommented:
Does ShellExecute or WinExec or CreateProcess help?
0
IndefreiCommented:
to run an exefile
1.
put the FMXUtils unit in your uses clause
 
Syntax is
ExecuteFile( AppName, Parameters, StartDir, SW_showstyle);

e.g. ExecuteFile('Notepad.exe', '', '', SW_SHOWMAXIMIZED);

or
2.
WinExec('c:.\Myprog.EXE',SW_SHOWNORMAL);

Regards
Indi
0
IndefreiCommented:
Appendix
you'll find FMXUtils  in
....\Borland\delphi\demos\doc\Filmanex
0
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Fatman121898Commented:
I do it this way:

function ExecApplication(APPName,cmdLine: String; ShowMode: DWord; WaitToExit: Boolean): DWord;
//executes as well WIN and DOS app
  var
    StartInfo: TStartupInfo;
    ProcInfo: TProcessInformation;
  begin
    StartInfo.cb:=SizeOf(StartInfo);
    FillChar(StartInfo,
             SizeOf(StartInfo), 0);
    StartInfo.dwFlags:=
      STARTF_USESHOWWINDOW;
    StartInfo.wShowWindow:=
      ShowMode;
    if AppName<>''
      then
        CreateProcess(PChar(APPName),
                      PChar(CmdLine),
                      nil, nil, False,
                      0, nil, nil,
                      StartInfo,
                      ProcInfo)
      else
        CreateProcess(nil,
                      PChar(CmdLine),
                      nil, nil, False,
                      0, nil, nil,
                      StartInfo,
                      ProcInfo);
    if WaitToExit
       then
         WaitForSingleObject    
                     (ProcInfo.hProcess,
                      INFINITE);
    GetExitCodeProcess
                     (ProcInfo.hProcess,
                      Result);
  end;

The core is API function CreateProcess.

Parameters:
APPName: application name (including path) - optional;
CmdLine: command parameters line;
ShowMode: visibility parameter (allowed values: SW_HIDE, SW_MAXIMIZE, SW_MINIMIZE and others - see
help info for ShowWindows API function);      
WaitToExit: wether to wait process to exit.

You could use CmdLine to pass applications name instead APPName.

Examples:

//statement:
ExecApplication('C:\MyProgs\ABC.EXE','-a -b -c', SW_MINIMIZE, False);
//is equal to:
ExecApplication('','C:\MyProgs\ABC.EXE -a -b -c', SW_MINIMIZE, False);

Jo.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
MadshiCommented:
Hi Fatman, how about writing a *comment* next time? You were not the first one in this thread...   :-)
0
Fatman121898Commented:
Oops, sorry, didn't know that only the first one can write *answer*  .-)
Jo.
0
MadshiCommented:
Well, of course you *can* write an answer, though you're not the first one. But here in the Delphi forum (and only here) most experts only write comments to give the questioner the possibility to choose the best comment. *I* post answers only, if I'm the first one and if I'm quite sure that my answer is really complete.

I wish EE would drop answers at all. Should be no problem now, since the questioners can accept any comment as the answer (new EE feature).
0
dingchengAuthor Commented:
Thank Madshi and Indeferi.Thank you for your sincere help.  
0
IndefreiCommented:
Lol :O)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Delphi

From novice to tech pro — start learning today.