type
PRaiseFrame = ^TRaiseFrame;
TRaiseFrame = record
NextRaise: PRaiseFrame;
ExceptAddr: Pointer;
ExceptObject: TObject;
ExceptionRecord: PExceptionRecord;
end;
procedure TMyThread.Execute;
procedure SynchronizeException;
var
SendException: TObject;
begin
if RaiseList <> nil then
begin
SendException := PRaiseFrame(RaiseList)^.ExceptObject;
PRaiseFrame(RaiseList)^.ExceptObject := nil;
PostMessage(Form1.Handle, THREAD_EXCEPTION, 0, Integer(Pointer(SendException)));
end;
end;
begin
try
raise Exception.Create('Hello world');
except
SynchronizeException
end;
end;
procedure tform1.onthreadexception(var msg: tmessage);
//message THREAD_EXCEPTION
var
E: Exception;
begin
E := Exception(msg.lParam);
raise E;
end;