Page 1 of 1

Function return the dll ??

Posted: Sat Apr 30, 2016 12:33 pm
by Ale SB
Good Morning ;

How could I get the return of a function in the DLL harbour?

MyDll.dll

Code: Select all

FUNCTION MSGPARAM()
  local cTitulo:="Msg Sem Parametros"
  MsgInfo(cTitulo)
  
return "Test Return"

********************************************************************************
#pragma BEGINDUMP
  #include <windows.h>
  #include <hbvm.h>
  #include <hbapi.h>
  #include <hbapiitm.h>
  
#define DllExport __declspec( dllexport )
  #define DllImport __declspec( dllimport )
  
  BOOL WINAPI DllMain( HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved )
  {
  HB_SYMBOL_UNUSED( hinstDLL );
  HB_SYMBOL_UNUSED( fdwReason );
  HB_SYMBOL_UNUSED( lpvReserved );
  switch( fdwReason )
  {
   case DLL_PROCESS_ATTACH:
    hb_vmInit( FALSE );
    break;
   case DLL_PROCESS_DETACH:
    hb_vmQuit();
    break;
  } 
  return TRUE;
  }

  DllExport void __cdecl MSGPARAM()
  { 
    hb_itemDoC( "MSGPARAM", 0 );
  }


  DllExport void __cdecl HBDLLENTRY( char * cProcName )
  {
    hb_itemDoC( cProcName, 0 );    
  }

#pragma ENDDUMP
 
MyPrg.prg

Code: Select all

     hLib := hb_libLoad( "Mydll.dll" )       
     if !Empty( hLib )
          hb_DynCall( { "MSGPARAM", hLib, hb_bitOr( HB_DYN_CTYPE_CHAR_PTR , HB_DYN_CALLCONV_CDECL ) } )         
        hb_libFree( hLib )

//--//--//

     hLib := hb_libLoad( "Mydll.dll" )       
     if !Empty( hLib )
          hb_DynCall( { "HBDLLENTRY", hLib, hb_bitOr( HB_DYN_CTYPE_CHAR_PTR , HB_DYN_CALLCONV_CDECL )  },"MSGPARAM" )
        hb_libFree( hLib )
 
Regards, Ale SB