On Sunday 13 September 2009 23:38:08 Jonas Maebe wrote: > If the behaviour is different in Delphi. at least in kylix.
this works in kylix and not in fpc $ cat hooks2.pas program hooks; {$IFDEF FPC} {$mode delphi} {$ENDIF} uses SysUtils,Classes,Types; {$IFNDEF FPC} type PtrUInt = DWord; // DCC is 32 bit function HexStr(P:Pointer) : String; begin HexStr:=IntToHex(PtrUInt(P),4); end; {$ENDIF} type TMethod_1Param = procedure(Value:integer=0) of object; procedure Hook_M_1Param(aMethod: TMethod_1Param); begin writeln('Hooked: Method.Code:',HexStr(TMethod(aMethod).Data), ' Method.Data:',HexStr(TMethod(aMethod).Code)); TMethod_1Param(aMethod)(143); end; type TC = class(TObject) public F : integer; constructor Create; procedure M_1Param(Value:integer=0); end; constructor TC.Create; begin inherited Create; F:=142; Hook_M_1Param(M_1Param); end; procedure TC.M_1Param(Value:integer); begin writeln('M_1Param called with Value:',Value,' and F is:',F); end; var C : TC; begin C:=TC.Create; end. _______________________________________________ fpc-devel maillist - fpc-devel@lists.freepascal.org http://lists.freepascal.org/mailman/listinfo/fpc-devel