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.

_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to