OT: .DLL interface

Re: OT: .DLL interface

Postby TimStone » Thu Oct 14, 2010 12:22 am

It actually ties two programs together ... mine, and a parts supplier. My program calls the .dll which communicates with their program on the same computer. The lookup parts and save them.

The problem here is the communication. Its all done in XML so that takes parsing, but I'm not concerned with that. I have samples of programs written in Delphi and VB that can do this without a problem, but apparently we can't do it with native xHarbour/FWH.

Calling the .dll's is not a problem except for the very first one. We must define a function in the xHarbour program, and pass its memory location to the .dll ( which is interacting with their other program ). Then, their program calls that function to pass the XML document.

If you look at Antonio's work ( greatly appreciated ), you can see how he approached this, and my sample code works except for getting the document. In other words, that function info is accepted by the .dll, and then I can actually affirmatively connect to the program and get a response. Once that occurs I'm supposed to receive a "Hello" document but so far I'm not seeing it.

The problem here is my lack of knowledge of C. I have the compilers I need, the books yet unstudied, etc. etc. but I've always gotten around it. I decided enough was enough so now I'm actually studying at least the basics of C so I can actually work with the EXTEND API for xHarbour. Perhaps then I will get this working.

Tim
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2909
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: OT: .DLL interface

Postby Antonio Linares » Thu Oct 14, 2010 6:51 am

Tim,

Please send me your EXE inside a ZIP file renamed as *.ZOP, thanks :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
User avatar
Antonio Linares
Site Admin
 
Posts: 41462
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Re: OT: .DLL interface

Postby TimStone » Sat Oct 16, 2010 4:48 pm

Per your comments on the behavior of the xCC compiler, I want to try it with xBuilder and the Microsoft C compiler ( I have VS 2008 & 2010 on this computer ) but so far the two are not happy together ... I'm working on it.
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2909
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Re: OT: .DLL interface

Postby TimStone » Fri Oct 22, 2010 9:18 pm

First, many thanks to Antonio and others who helped me with this problem.

Secondly, we all need to master the basics of C programming because we will have a continuing need to interface with other products, and the xHarbour EXTEND system will enable us to do this.

The problem here was to pass a pointer to a FUNCTION created with xHarbour, to an external DLL, and the method in it would pass an XML document to that function which would make it available in our main program.

Here is the code Antonio suggested:

Code: Select all  Expand view


#pragma BEGINDUMP

#include <windows.h>
#include <hbvm.h>

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 );

}

#pragma ENDDUMP



FUNCTION main  //  wpac
 
  LOCAL cXMLDoc := "0"
    // Register the procedure
    Register( )
   
RETURN NIL

   
// Procedure( XMLDoc :LPSTR; Size :INT )
FUNCTION CalledBack( cXML, nSize )

    MsgInfo( cXML )

RETURN NIL

 
Tim Stone
http://www.MasterLinkSoftware.com
http://www.autoshopwriter.com
timstone@masterlinksoftware.com
Using: FWH 23.10 with Harbour 3.2.0 / Microsoft Visual Studio Community 2022-24 32/64 bit
User avatar
TimStone
 
Posts: 2909
Joined: Fri Oct 07, 2005 1:45 pm
Location: Trabuco Canyon, CA USA

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 136 guests