tw2177.pp 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. { %version=1.1 }
  2. { Source provided for Free Pascal Bug Report 2177 }
  3. { Submitted by "Rimgaudas" on 2002-10-14 }
  4. { e-mail: [email protected] }
  5. {$ifdef fpc}{$mode delphi}{$endif}
  6. uses
  7. SysUtils;
  8. type
  9. ii= interface
  10. ['{616D9683-88DC-4D1C-B847-1293DDFBACF7}']
  11. procedure Show;stdcall;
  12. end;
  13. Twii= class(TObject, ii)
  14. s: string;
  15. function QueryInterface(const IID: TGUID; out Obj): Integer; stdcall;
  16. function _AddRef: Integer; stdcall;
  17. function _Release: Integer; stdcall;
  18. procedure Show;stdcall;
  19. end;
  20. {________doomy interfaces______}
  21. function Twii.QueryInterface(const IID: TGUID; out Obj): Integer; stdcall;
  22. begin
  23. result:= -1;
  24. end;
  25. function Twii._AddRef: Integer; stdcall;
  26. begin
  27. result:= -1;
  28. end;
  29. function Twii._Release: Integer; stdcall;
  30. begin
  31. result:= -1;
  32. end;
  33. {________doomy interfaces______}
  34. procedure Twii.Show;stdcall;
  35. begin
  36. WriteLn(s);
  37. end;
  38. var
  39. wii: twii;
  40. i: ii;
  41. begin
  42. try
  43. wii:= Twii.create;
  44. wii.s:='OK';
  45. i:= ii(wii);
  46. i.Show;
  47. except //excepts
  48. on EAccessViolation do WriteLn('Access Violation');
  49. else
  50. WriteLn('Problem');
  51. halt(1);
  52. end;
  53. end.