[fpc-pascal] Catching exception generated by another program

leledumbo leledumbo_cool at yahoo.co.id
Mon Jun 15 07:45:41 CEST 2009


Suppose I have a program written in C:

#include <stdio.h>

int main() {
  return 1 / 0;
}

and a Pascal program that calls it:

program prog;

{$mode objfpc}{$H+}

uses
  SysUtils;

begin
  try
    ExecuteProcess('tes.exe','');
  except
    on e: Exception do begin
      WriteLn(e.Message);
    end;
  end;
  WriteLn('Done').
end.

How can I catch the exception generated by the C program (note that it can
be a DLL too)?
The above approach doesn't catch it. The C program terminates abnormally as
usual, and the Pascal program goes by itself (proven by string 'Done' gets
written correctly).

-- 
View this message in context: http://www.nabble.com/Catching-exception-generated-by-another-program-tp24029070p24029070.html
Sent from the Free Pascal - General mailing list archive at Nabble.com.




More information about the fpc-pascal mailing list