xHarbour builder & FWH - workaround

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

xHarbour builder & FWH - workaround

Post by Antonio Linares »

There is a problem with the most recent xHarbour builder and FWH. Copy this code in your main PRG and it fixes it:

Code: Select all

#pragma BEGINDUMP

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

typedef struct
{
   FARPROC farProc;
   BYTE bType;
   BYTE bReturn;
   BYTE bParams;
   BYTE bParam[ 15 ];
} STRFUNC;

HB_FUNC( GETPROCADDRESS )
{
   STRFUNC strFunc;
   BYTE b = 0;
   BYTE bFunc[ 4 ];

   strFunc.bParams = hb_pcount() - 4;
   
   if( ISNUM( 2 ) )
   {
      bFunc[ 0 ]      = hb_parni( 2 );
      bFunc[ 1 ]      = 0;
      strFunc.farProc = GetProcAddress( ( HMODULE ) hb_parnl( 1 ), ( LPSTR ) bFunc );
   }
   else
      strFunc.farProc = GetProcAddress( ( HMODULE ) hb_parnl( 1 ), hb_parc( 2 ) );

   strFunc.bType      = hb_parl( 3 );
   strFunc.bReturn    = hb_parni( 4 );

   while( b < strFunc.bParams )
   {
      strFunc.bParam[ b ] = hb_parni( 5 + b );
      b++;                // keep this here cause Borland 5
   }

   hb_retclen( ( char * ) &strFunc, sizeof( STRFUNC ) - 15 + strFunc.bParams );
}

#pragma ENDDUMP 
regards, saludos

Antonio Linares
www.fivetechsoft.com
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Post by dpaterso »

Hello, sorry, me again!

I copied (cut & pasted) the temporary fix into my main .prg but when compiling I now get the following xHB error:

hbole.h Line 62 Error F0026 Parse error in constant expression '\'

Help!

Regards,

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

Post by Antonio Linares »

Dale,

What xHarbour builder version or RC are you using ?

Have you tried with a fresh install of xHarbour builder ? Here it works ok.
regards, saludos

Antonio Linares
www.fivetechsoft.com
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Post by dpaterso »

Hello,

I am using the latest release of XHB i.e. August 2006 RC-8.

I always uninstall my current version and re-install the new one each time a new release is made available so there is no chance that it is a corrupt installation or contains old or modified files. I do the same with FWH.

Regards,

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

Post by Antonio Linares »

Dale,

Please build this sample with xHB. It should build and work ok with no problems. Let us know if it works ok, thanks.

Code: Select all

#include "FiveWin.ch"

function Main() 

   MsgInfo( GetCPU() )
   ShellExecute( 0, 'Open', 'http://www.google.com/' )
   
return nil

#pragma BEGINDUMP

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

typedef struct
{
   FARPROC farProc;
   BYTE bType;
   BYTE bReturn;
   BYTE bParams;
   BYTE bParam[ 15 ];
} STRFUNC;

HB_FUNC( GETPROCADDRESS )
{
   STRFUNC strFunc;
   BYTE b = 0;
   BYTE bFunc[ 4 ];

   strFunc.bParams = hb_pcount() - 4;
   
   if( ISNUM( 2 ) )
   {
      bFunc[ 0 ]      = hb_parni( 2 );
      bFunc[ 1 ]      = 0;
      strFunc.farProc = GetProcAddress( ( HMODULE ) hb_parnl( 1 ), ( LPSTR ) bFunc );
   }
   else
      strFunc.farProc = GetProcAddress( ( HMODULE ) hb_parnl( 1 ), hb_parc( 2 ) );

   strFunc.bType      = hb_parl( 3 );
   strFunc.bReturn    = hb_parni( 4 );

   while( b < strFunc.bParams )
   {
      strFunc.bParam[ b ] = hb_parni( 5 + b );
      b++;                // keep this here cause Borland 5
   }

   hb_retclen( ( char * ) &strFunc, sizeof( STRFUNC ) - 15 + strFunc.bParams );
}

#pragma ENDDUMP 
regards, saludos

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

Post by Antonio Linares »

Dale,

There is a simpler solution. Please add these lines into FiveWin.ch:

Code: Select all

#ifdef __XHARBOUR__
   REQUEST GetProcAddress
#endif
regards, saludos

Antonio Linares
www.fivetechsoft.com
dpaterso
Posts: 142
Joined: Tue Jan 24, 2006 9:45 am
Location: South Africa
Contact:

Post by dpaterso »

Thanks very much for the help.

I tried both methods and both work perfectly - thanks.

I must apologise to you for posting the compile error. I did not realise that I had a comment before the '#pragma BEGINDUMP' statement i.e. I had '***#pragma BEGINDUMP'. Careless! Sorry about that!

Once again, thanks for the help.

Regards,

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

Post by Antonio Linares »

Dale,

You are welcome. Glad to know it is working fine :)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply