pipinana2002
asked on
Call Delphi Program from another Delphi program
Hi all..
Let's say I have 2 Delphi programs.. just call it Father and Son.
Father has 50 statements and Son has 10 statements to execute when they are called/runned.
If first we run Father, at statement no 20, Father will call Son. When this happens, Son will execute his 10 statements. I want to make it such that: the Father will only continue to run his statements (statement 21 - 50) AFTER Son has finished executing his 10 statements. So it's like Father will wait until the Son finishes his statements then the Father will continue his statements.
Is there any way I can do this? I think for calling another delphi program, we have to use winexec is it?
Thankss for your help :)
Let's say I have 2 Delphi programs.. just call it Father and Son.
Father has 50 statements and Son has 10 statements to execute when they are called/runned.
If first we run Father, at statement no 20, Father will call Son. When this happens, Son will execute his 10 statements. I want to make it such that: the Father will only continue to run his statements (statement 21 - 50) AFTER Son has finished executing his 10 statements. So it's like Father will wait until the Son finishes his statements then the Father will continue his statements.
Is there any way I can do this? I think for calling another delphi program, we have to use winexec is it?
Thankss for your help :)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
you really don't need the tmpFileName variable in my example... I modified some old code I had.....
ASKER
Hi all..
Thank you for all your answer.. I will test the code first and I'll get back to u :) Thanksssss...
Thank you for all your answer.. I will test the code first and I'll get back to u :) Thanksssss...
Is the a reason for Son to be a exe? If not why not make Son a dll. Then simply call it at line 20.
I wrote a IPC components designed to allow InterProcess Communications between to processes
try this link at torrys http://www.torry.net/vcl/system/appcommunications/bmipc.zip
What I used it for in the past was to send a message to another one of my apps to do something.
So what you could do is have the father wait until the son sends a message to continue on with the rest of the process
Bill
try this link at torrys http://www.torry.net/vcl/system/appcommunications/bmipc.zip
What I used it for in the past was to send a message to another one of my apps to do something.
So what you could do is have the father wait until the son sends a message to continue on with the rest of the process
Bill
ASKER
HI all.. thanks for all your answer, especially to TomGrills.. hehehe I finally can make i work ;)
procedure ExecExtern;
const
MAXTIME=5000; // max wait 5 seconds
var
tp,tk: dword;
exitcode: dword;
procinf: PROCESS_INFORMATION;
stinfo: STARTUPINFO;
begin
GetStartupInfo(stinfo);
// if You want to show Son
stinfo.wShowWindow := SW_SHOW
// if You want to hide Son
stinfo.wShowWindow := SW_HIDE;
// start son
CreateProcess(nil,PChar('Y
// waiting for Son end not more then MAXTIME
tp := GetTickCount;
while tp + MAXTIME > GetTickCount do
begin
// Application.ProcessMessage
if not GetExitCodeProcess(procinf
break;
if exitcode <> STILL_ACTIVE then
break;
end;
end;