Re:CreateProcess - Tricky One?
Quote
Erik Sperling Johansen wrote:
> Off topic, but...
> When you've located the window handle of the previous form, send it a
> custom message to determine whether it is alive or being designed.
> Create a message handler that returns some funny value when it receives
> the message. Then you won't have to worry about forms in design mode.
Ahh, top tip, thanks!!
Quote
> Hmmm...
> This other app, does it somehow communicate with your app? Does it
> inherit handles?
No it does'nt talk to my app at all, to fill you in a bit, it's a fidonet
mail tosser which at times needs to run another app to create special
archived packets of mail, I've set it to not inherit the handle from my
app but what it does when running the compression program I don't know.
Quote
> Try replacing WaitForSingleObject with something like this? (I'm just
> guessing now)
> while WaitForSingleObject(ProcessInfo.hProcess, 0)<>WAIT_OBJECT_0 do
> begin
> Application.ProcessMessages;
> end;
You may have already recieved my message on the Delphi Experts Web Page,
but in case you havent and for the benefit of others that may come
across a similar problem I did managed to get around the problem in a
similar way to what you've suggested above, and I would expect the above
would work also although I havent tried it and to be honest now that
it's finally working I'm going to leave it alone. Here's what I did:
GetExitCodeProcess(PROCESS_INFORMATION.hProcess, FExitCode);
while FExitCode = STILL_ACTIVE do
begin
Application.ProcessMessages;
GetExitCodeProcess(PROCESS_INFORMATION.hProcess, FExitCode);
end;
This seems to work like a charm, so I'm a happy little vegemite.
Thankyou once again Erik for your help here, hope I may get the chance
return the favour sometime!
James