Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

How do I launch an external App. ??

Posted on 1998-04-03
5
Medium Priority
?
181 Views
Last Modified: 2010-04-06
How do I launch an external Application from D2.0 and wait for it to end (just like system() does in C/C++) ??
A little more information : the Application is a DOS based one, so it receives some parameters from command line and creates some output files.

I'm sure this is a very simple question, just want to know what **function or procedure** to call from inside my D2.0 app.

Besides, does anybody (expert I mean) know how many lines a Memo can store, depends on the TMemo implementation or on the amount of memory available on the system ??

thanx. Rigansen.
0
Comment
Question by:rigansen
[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
  • 4
5 Comments
 
LVL 1

Accepted Solution

by:
Edo082297 earned 80 total points
ID: 1361263
Hi Rigansen,


function CreateProcessSimple(sExecutableFilePath : string):string;
var
  pi: TProcessInformation;
  si: TStartupInfo;
begin
  FillMemory( @si, sizeof( si ), 0 );
  si.cb := sizeof( si );

  CreateProcess( Nil,    PChar( sExecutableFilePath ),   Nil, Nil, False,   NORMAL_PRIORITY_CLASS, Nil, Nil,  si, pi );

  // "after calling code" such as
  // the code to wait until the
  // process is done should go here  

  CloseHandle( pi.hProcess );
  CloseHandle( pi.hThread );
end;      
Now, all you have to do is call CreateProcessSimple(), let's say to run Windows' Notepad:
CreateProcessSimple( 'notepad' );      

It's that... simple.

Regards,

Edward

0
 
LVL 1

Expert Comment

by:Edo082297
ID: 1361264
I believe that the TMemo component has a (theoretical) limit of 2 gigabytes! The operating system will limit the number of characters the user can enter if memory limit has been reached.
0
 
LVL 1

Expert Comment

by:Edo082297
ID: 1361265
Hi again and sorry, I'm not paying attention to the question you asked. To get the Delphi to wait for the process to end, use

WaitforSingleObject(ProcessInfo.hProcess,INFINITE);

You have to load the process handle (hProcess) into the ProcessInfo structure when you use CreateProcess.



0
 
LVL 2

Author Comment

by:rigansen
ID: 1361266
but...

what about using WinExec() ?

what about executing a .BAT file ?


can you help me on that ??
0
 
LVL 1

Expert Comment

by:Edo082297
ID: 1361267
Hi Rigansen

   Sorry for not getting back sooner, I only happened to notice you asked for more info when reviewing another question!
   WinExec is implemented as a call to CreateProcess, and yes, you can use it. However, it remains only for backwards compatibility, and this means that you should only use CreateProcess. Besides, it allows you more control over the process.
   About the .BAT file, you'll have to post :) My DOS is limited (ironically) and since M$ took the help file out, I really can't tell you - the only BAT files I write are to do update files across networks and the likes (simple copies, etc...).

Regards,
Edo
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

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…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

636 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