by mauricioajordao » Thu Mar 02, 2006 11:39 pm
Dear Antonio,
Thanks per Help make My DLL to Xharbour, But Now i Have Other Problem..
My Dll its OK TO , Cobol , DELPHI , VB , But to Using Xharbour Calling Don´t RUN.
Do You Know Why?
i make My DLL With
macrocall.c
*************************************************
#define HB_OS_WIN_32_USED
#include "hbvm.h"
#include "hbapiitm.h"
#include "hbstack.h"
#if defined(HB_OS_WIN_32)
// Function pointer type
typedef long (__stdcall *CallBackFuncType)(const char* message);
// Setter function
HB_EXPORT __stdcall void SetCallBack(CallBackFuncType fun);
// funcao Macrocall
void * HB_EXPORT __stdcall MacroCall( char * sfunc, char *schar)
{
char *szFunc = "MacroCall";
PHB_DYNS pDynSym = hb_dynsymFindName( szFunc ); /* The PRG function to use */
if( pDynSym )
{
hb_vmPushSymbol( pDynSym->pSymbol );
hb_vmPushNil();
hb_vmPushString( sfunc, strlen( sfunc ) );
hb_vmPushString( schar, strlen(schar) );
hb_vmFunction( 2 ); /* as we receive one parameter */
strcpy( schar , hb_stack.Return.item.asString.value ) ;
return "0" ;
}
else
return "0" ;
}
static CallBackFuncType cbfun = 0;
void __stdcall SetCallBack(CallBackFuncType fun)
{
CallBackFuncType oldfun = cbfun;
cbfun = fun;
return oldfun;
}
HB_FUNC( CALLBACK )
{
long result = 0;
if (cbfun != 0)
{
result = cbfun( hb_parc( 1 ) );
}
else
{
MessageBox( NULL, //HWINDOW of the window that owns the message box
"CallBack failed under MacrCall.c" , //Text
"Warning" ,//Title
MB_OK | MB_ICONINFORMATION );//Bit mask flags
}
hb_retl( result ); // QUESTION: If you can make this to return a char pointer
// being interpreted correctly by Delphi,
// please inform me, I'm all ears, thank you.
}
HB_FUNC( MSGBOX )
{
MessageBox( 0, hb_parc( 1 ), "Warning", 0 );
}
#endif
*****************************
maindll
#define HB_OS_WIN_32_USED
#include "hbvm.h"
#include "hbapiitm.h"
#if defined(HB_OS_WIN_32)
BOOL HB_EXPORT WINAPI DllEntryPoint( HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved )
{
HB_TRACE( HB_TR_DEBUG, ("DllEntryPoint(%p, %p, %d)", hInstance, fdwReason,
pvReserved ) );
HB_SYMBOL_UNUSED( hInstance );
HB_SYMBOL_UNUSED( fdwReason );
HB_SYMBOL_UNUSED( pvReserved );
switch( fdwReason )
{
case DLL_PROCESS_ATTACH:
hb_vmInit( FALSE ); /* Don't execute first linked symbol */
break;
case DLL_PROCESS_DETACH:
/* hb_vmQuit(); */
break;
}
return TRUE;
}
LONG HB_EXPORT PASCAL HBDLLENTRY( char * cProcName )
{
hb_itemDoC( cProcName, 0, 0 );
return 0;
}
#endif
**************************
My Call in xharbour
DLL32 FUNCTION chamada(parm1 AS LPSTR , parm2 AS LPSTR) AS LONG PASCAL FROM "macrocall" LIB "XHB.DLL"
Thanks For help...