The tricky requirement is that we had to identify a memory location to register with their program to receive the data. The following functions perform all of the interface we need.
This code works fine with xHarbour builds. However, I'm now working with MSVC / Harbour. I created a .lib file from the .dll and linked it in ( just like the one we created for the xHarbour version ). It is built with Lib.exe from Visual Studio.
Here is the code used in xHarbour.
- Code: Select all Expand view
// Primary functions to use
void __declspec(dllexport) RcvProcedure( char * szXML, LONG lSize )
{
hb_vmPushSymbol( hb_dynsymGetSymbol( "CALLEDBACK" ) ); // we push the symbol of the function to call
hb_vmPushNil(); // we push nil for a function, a codeblock for Eval, an object for a method
hb_vmPushString( szXML, strlen( szXML ) );
hb_vmPushLong( lSize );
hb_vmFunction( 2 ); // two parameters supplied to CallBack()
}
// Declare Sub WCAPRegisterReceive Lib "wcap.dll" _ (ByVal lpRcvProcedure As Long)
void pascal WCAPRegisterReceive( LONG );
HB_FUNC( REGISTER )
{
WCAPRegisterReceive( ( LONG ) RcvProcedure );
}
// Function: WCAPConnectAs( Host:LPSTR, Port :UINT, Autostart :UINT ) :Bool
BOOL pascal WCAPConnectAS( LPSTR, LONG, LONG );
HB_FUNC( WPCONNECTAS )
{
hb_retl( WCAPConnectAS( ( char * ) hb_parc( 1 ), hb_parnl( 2 ), hb_parnl( 3 ) ));
}
// Function: WCAPConnected :BOOl
BOOL pascal WCAPConnected( );
HB_FUNC( WPCONNECTED )
{
hb_retl( WCAPConnected() );
}
// Function: WCAPDisconnect
void pascal WCAPDisconnect();
HB_FUNC( WPDISCONNECT )
{
WCAPDisconnect() ;
}
// Function: WCAPSend(XMLDoc :LPSTR)
void pascal WCAPSend( LPSTR );
HB_FUNC( WPSEND )
{
WCAPSend( ( char * ) hb_parc( 1 ) );
}
When trying to build with Harbour / MSVC, I get the following errors:
- Code: Select all Expand view
--------------------Configuration: ASW2013 - Release--------------------
FiveHC32.lib(MEM.obj) : warning LNK4006: _HB_FUN_NEXTMEM already defined in errsysw_.obj; second definition ignored
hbvm.lib(hvmall.obj) : warning LNK4006: _HB_FUN_HB_GCALL already defined in tCodeJock.obj; second definition ignored
Creating library asw2012.lib and object asw2012.exp
wPac.obj : error LNK2019: unresolved external symbol "void __stdcall WCAPRegisterReceive(long)" (?WCAPRegisterReceive@@YGXJ@Z) referenced in function _HB_FUN_REGISTER
wPac.obj : error LNK2019: unresolved external symbol "int __stdcall WCAPConnectAS(char *,long,long)" (?WCAPConnectAS@@YGHPADJJ@Z) referenced in function _HB_FUN_WPCONNECTAS
wPac.obj : error LNK2019: unresolved external symbol "int __stdcall WCAPConnected(void)" (?WCAPConnected@@YGHXZ) referenced in function _HB_FUN_WPCONNECTED
wPac.obj : error LNK2019: unresolved external symbol "void __stdcall WCAPDisconnect(void)" (?WCAPDisconnect@@YGXXZ) referenced in function _HB_FUN_WPDISCONNECT
wPac.obj : error LNK2019: unresolved external symbol "void __stdcall WCAPSend(char *)" (?WCAPSend@@YGXPAD@Z) referenced in function _HB_FUN_WPSEND
asw2012.exe : fatal error LNK1120: 5 unresolved externals
MLS2013.EXE - 6 error(s), 2 warning(s)
Any ideas on how to get this to work would be greatly appreciated.
Tim