Board index » delphi » exec child from parent prog.

exec child from parent prog.

I have a mian menu program of which three of the options are to
execute child programs and basically I can't seem to get it going.

All four programs are completed but I can't seem to link them
together.  All the text books I have are useless in this area.

I've managed to figure out that it's got something to do with the
- exec - command in the DOS unit and other related commands are
- swapvectors - and - DosExitCode -.

But I seem to be going around in circles.

main prog

parent - login2.pas

child progs - password.exe
              applicat.exe
              accounts.exe

If anyone know the correct syntax to do this could they possibly
send it to me please.

Thanks in advance.

dan.

 

Re:exec child from parent prog.


D.>Original Sender: "D.J.Rainsford" <dr6...@humus.ucc.hull.ac.uk>

D.>I have a mian menu program of which three of the options are to
D.>execute child programs and basically I can't seem to get it going.

D.>All four programs are completed but I can't seem to link them
D.>together.  All the text books I have are useless in this area.

D.>I've managed to figure out that it's got something to do with the
D.>- exec - command in the DOS unit and other related commands are
D.>- swapvectors - and - DosExitCode -.

D.>But I seem to be going around in circles.

D.>main prog

D.>parent - login2.pas

D.>child progs - password.exe
D.>              applicat.exe
D.>              accounts.exe

D.>If anyone know the correct syntax to do this could they possibly
D.>send it to me please.

D.>Thanks in advance.

D.>dan.

PROGRAM ExecChild;
begin
   SwapVectors;
   Exec(Get Env('COMSPEC'),'/C PASWORD.EXE');
   SwapVectors;
end;

        -- Kim Forwood --

  /-=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=-\
  $           Kim Forwood  <kim.forw...@access.cn.camriv.bc.ca>          %
  %         For what purpose is life, if one cannot live freely?         $
  \-=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=--=oOo=-/

Re:exec child from parent prog.


Quote
"D.J.Rainsford" <dr6...@humus.ucc.hull.ac.uk> wrote:

>I have a mian menu program of which three of the options are to
>execute child programs and basically I can't seem to get it going.

>All four programs are completed but I can't seem to link them
>together.  All the text books I have are useless in this area.

>I've managed to figure out that it's got something to do with the
>- exec - command in the DOS unit and other related commands are
>- swapvectors - and - DosExitCode -.

>But I seem to be going around in circles.

>main prog

>parent - login2.pas

>child progs - password.exe
>              applicat.exe
>              accounts.exe

>If anyone know the correct syntax to do this could they possibly
>send it to me please.

>Thanks in advance.

>dan.

When you use Exec from the Dos unit, you need to include the
{$M Stack, MinHeap, MaxHeap} compiler directive.
if you do not allocate any memory in your program using New or GetMem,
then it should be safe to put {$M 16384,0,0}, but if you use any memory
allocation in your program, you will have to guess how much memory you
have to have and how much to use as Max.

By default the compiler uses {$M 16384,0,655360} which gives you 16K
stack with all available memory belonging to this task, which does not
allow you to spawn to a child process.

If you want to see the current compiler directives press Ctrl-O,O
The directives will be inserted into the current file at the top, the
second line containing the {$M} directive, I'm prety sure the last value
is 655360 which is causing your problem.

Hope this helps.

Other Threads