test.prg
- Code: Select all Expand view
#include "FiveWin.ch"
static pOld
function Main()
pOld := FunSwap( "TIME", "MYTIME" )
MsgInfo( Time() ) // We have replaced the original Time() function! :-)
return nil
function MyTime()
local uRet := ExecPtr( pOld ) // in case that we want to call the original function
return "now"
#pragma BEGINDUMP
#include <hbapi.h>
typedef void ( * PFUNC ) ( void );
HB_FUNC( FUNSWAP )
{
PHB_SYMB symFirst = hb_dynsymSymbol( hb_dynsymFindName( hb_parc( 1 ) ) );
PHB_SYMB symLast = hb_dynsymSymbol( hb_dynsymFindName( hb_parc( 2 ) ) );
PHB_FUNC pFirst = symFirst->value.pFunPtr;
symFirst->value.pFunPtr = symLast->value.pFunPtr;
hb_retnl( ( LONG ) pFirst );
}
HB_FUNC( EXECPTR )
{
PFUNC p = ( PFUNC ) hb_parnl( hb_pcount() );
p();
}
#pragma ENDDUMP