Harbour C-Wrapper Help

Post Reply
Bill Simmeth
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA
Contact:

Harbour C-Wrapper Help

Post 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!
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
pawelu
Posts: 126
Joined: Thu Oct 06, 2005 10:18 pm
Location: Poland
Contact:

Post by pawelu »

Bill,

try this:

Code: Select all

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

Pawel
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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 );
regards, saludos

Antonio Linares
www.fivetechsoft.com
Bill Simmeth
Posts: 42
Joined: Wed Oct 26, 2005 1:20 pm
Location: Marshall, Virginia, USA
Contact:

Post 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--() ?
Bill Simmeth
Merchant Software Corp
Marshall, Virginia USA
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post 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
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply