Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to Raise Exception from a ShellExecuted Delphi program into the Parent Delphi program

Status
Not open for further replies.

6volt

Programmer
Jun 4, 2003
74
0
0
US
I have a Delphi program, A, which runs another Delphi program, B, using CreateProcess (or ShellExecute)

The return code from CreateProcess merely indicates whether the process was successfully created so it is useless when trying to RAISE ERRORS.

The only way I can think of doing it is to have B create a file with an error message ON Exception.

When A detects that the B process is finished, go and look for the B error file, read the error and then RAISE an error with the appropriate E.message.

HOWEVER, There simply has to be an elegant way to do this since this should be a common occurrence.

Thanks in advance,
Tom



 
Check out ErrorLevel (yup, that same one you once used in batch files :))
 
Hi, Thanks for the ErrorLevel suggestion.

However, I'm not sure exactly how it works:

1) Does it report the Last Error any process incurred? If Yes, you would not know when that error occurred - it could have been from hours or days ago.

2) OR, Does it report the Error of the last process to terminate? If Yes, does this include all system and other processes? Further, there could be many system processes that terminate AFTER the Delphi B program terminated.

Just thinking... When you CreateProcess, you get the Process Handle. Is there any way to see how a particular process terminated?

Thanks
Tom
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top