Page 1 of 1

Harbour C-Wrapper Help

Posted: Fri Jan 05, 2007 5:40 pm
by Bill Simmeth
Might someone help me with the C-wrapper syntax? I have looked at the Harbour website for documentation, but could find none on the c-wrappers.

I have the following code so far. I need to return the second element of the structure "ScanFindInfo". The second element is a string.

Code: Select all

#pragma BEGINDUMP

#include <hbapi.h>
#include <windows.h>
#include <scancapi.h>

HB_FUNC( FindScanner )
{
   SCAN__;
   HANDLE hFindHandle;
   DWORD dwResult;

   SI_INIT( &ScanFindInfo );
   dwResult = SCAN_FindFirst( &ScanFindInfo, &hFindHandle );
}

#pragma ENDDUMP
Thanks in advance!

Posted: Fri Jan 05, 2007 6:34 pm
by pawelu
Bill,

try this:

Code: Select all

dwResult = SCAN_FindFirst (&ScanFindInfo, &hFindHandle);
hb_retc (WideToAnsi (ScanFindInfo.szPortName)); // conversion for Unicode format

Pawel

Posted: Sat Jan 06, 2007 8:12 am
by Antonio Linares
Pawel,

Your code will produce memory leak. This is needed:

Code: Select all

char * p;

dwResult = SCAN_FindFirst (&ScanFindInfo, &hFindHandle); 
p = WideToAnsi (ScanFindInfo.szPortName);
hb_retc( p );
hb_xfree( p );

Posted: Mon Jan 08, 2007 4:58 pm
by Bill Simmeth
Pawel and Antonio thank you for the hints.

Antonio, is there a reference on the wrappers, for help on things like hb_parn--() ?

Posted: Mon Jan 08, 2007 5:37 pm
by Antonio Linares
Bill,

Harbour "extend system" is fully compatible with Clipper, so you can check a Clipper manual like this one:
http://www.ousob.com/ng/cltech/ng242.php