As I said in a comment on Zam, with the current version downloaded today in Acrobat Reader DC, I get the same error as you.
Please try this code and let us know if this avoids the error for you, because it certainly works for me, and there is no AV, either in FormClose or later.
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var Ref : Integer; begin Ref := AcroPdf1.ControlInterface._AddRef; AcroPdf1.Src := ''; AcroPdf1.Free; AcroPdf1 := Nil; end;
This is my FormCreate, which only contains my other code.
procedure TForm1.FormCreate(Sender: TObject); begin AFileName := 'd:\aaad7\pdf\printed.pdf'; AcroPdf1.src := AFileName; AcroPdf1.setZoom(200); // <- this line is to exercise the // ControlInterface to provoke the AV on shutdown end;
I have absolutely no idea why my FormClose avoiding the AV problem, and before anyone else says that, yes, it looks crazy to me too! It is unlikely that anything deserves the name "solution", but perhaps it will offer the right solution for those who know more about COM and Ole controls than I do.
I originally included Ref := AcroPdf1._AddRef as an experiment. I noticed that after it, the Ref value was 9. After AcroPdf1.Src := '' calling AcroPdf1._Release in the debugger evaluator returned 4. I was going to find out if AV could not be avoided by causing RefCount to drop by repeatedly calling _Release , but then Presto !, after my first release in FormClose there was no AV.
Update: I have not tested the following exhaustively, but this simplified FormClose also avoids AV, on my system, anyway:
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var Ref : Integer; begin Ref := AcroPdf1.ControlInterface._AddRef; end;
Obviously, the Ref assignment exception should not make any difference.
I am using Delphi 10 Seattle on 64-bit Win10, by the way.