[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

redirection in delphi 3

Posted on 1998-07-17
2
Medium Priority
?
234 Views
Last Modified: 2010-04-03
I NEED TO LAUNCH AN .EXE AND GET THE PARAMETERS FROM A FILE THAT IS NEEDED BY THE
EXE.  I'M TRYING TO USE A DOS COMMAND LIKE
MYPROG.EXE < FILENAME.EXT.   THIS IS CALLED REDIRECTION IN DOS, REDIRECTING THE COMMAND LINE KEYBOARD INPUT INTO A FILE.  I NEED TO KNOW HOW TO DO THIS IN DELPHI 3.
I CAN LAUNCH THE PROGRAM USING WINEXEC,SHELLEXECUTE, AND CREATEPROCESS; BUT I CAN'T PASS THE NEEDED PARAMETERS  FOR THAT .EXE.  
0
Comment
Question by:mlgwfis
[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
2 Comments
 
LVL 3

Expert Comment

by:vladika
ID: 1358087
I think you can pass file name as first parameter.
In the program you can read value of first parameter
and open file with name equal parameter's value.
Then read others parameters from this file.

0
 
LVL 8

Accepted Solution

by:
ZifNab earned 400 total points
ID: 1358088
Hi mlgwfis,

Brendan Delumpa of Delphi Corner already gave a solution to this :

.. CreateProcess .....

Okay, while the code above works just fine for executing an application, one my readers pointed out that it doesn't work with programs that
 include a command line argument. Why? Because CreateProcess' first parameter expects a fully qualified program name (path\executable) and
 nothing else! In fact, if you include a command line in that parameter, CreateProcess will do nothing. Yikes! In that case, you have to use the
 second argument. In fact, you can use the second parameter even for just executing a program with no command line. Given that,
 ExecNewprocess would be changed as follows:

 {Supply a fully qualified path name in ProgramName
  and any arguments on the command line. As the help file
  states: "If lpApplicationName is NULL, the first white space-delimited
  token of the command line specifies the module name..." In English,
  the characters before the first space encountered (or if no space is
  encountered as in a single program call) is interpreted as the
  EXE to execute. The rest of the string is the argument line.}
 procedure ExecNewProcess(ProgramName : String);
 var
   StartInfo  : TStartupInfo;
   ProcInfo   : TProcessInformation;
   CreateOK   : Boolean;
 begin

   { fill with known state }
   FillChar(StartInfo,SizeOf(TStartupInfo),#0);
   FillChar(ProcInfo,SizeOf(TProcessInformation),#0);
   StartInfo.cb := SizeOf(TStartupInfo);

   CreateOK := CreateProcess(nil, PChar(ProgramName), nil, nil,False,
               CREATE_NEW_PROCESS_GROUP+NORMAL_PRIORITY_CLASS,
               nil, nil, StartInfo, ProcInfo);

   { check to see if successful }
   if CreateOK then
     //may or may not be needed. Usually wait for child processes
     WaitForSingleObject(ProcInfo.hProcess, INFINITE);
 end;

you can find the whole page : http://www.delumpa.com/dc_main.html

Greetings, Zif.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone 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…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
In this video, Percona Solution Engineer Rick Golba discuss how (and why) you implement high availability in a database environment. To discuss how Percona Consulting can help with your design and architecture needs for your database and infrastr…
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…
Suggested Courses

656 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