tmakeobjinst.pp 550 B

12345678910111213141516171819202122232425262728293031323334
  1. { %opt=-S2 }
  2. { %target=win32 }
  3. uses
  4. windows,messages,classes;
  5. type
  6. tc1 = class
  7. procedure p(var msg : TMessage);
  8. end;
  9. tf = function (Window: HWND; Message, WParam: WPARAM;LParam: LPARAM): HRESULT; stdcall;
  10. procedure tc1.p(var msg : TMessage);
  11. begin
  12. if (msg.msg<>1) or (msg.wparam<>2) or (msg.lparam<>3) then
  13. halt(1);
  14. msg.result:=4;
  15. end;
  16. var
  17. f : tf;
  18. c : tc1;
  19. begin
  20. c:=tc1.create;
  21. f:=tf(MakeObjectInstance(@c.p));
  22. if f(0,1,2,3)<>4 then
  23. halt(1);
  24. c.free;
  25. FreeObjectInstance(f);
  26. writeln('ok');
  27. end.