FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour Accessing a Delphi DLL function.
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Accessing a Delphi DLL function.
Posted: Thu Oct 25, 2007 06:13 PM

Jeff,

I am not showing a[99], my code shows a[0].

In C language arrays are zero based, not 1 based, like in Clipper

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Accessing a Delphi DLL function.
Posted: Thu Oct 25, 2007 06:16 PM

Considering that a long value uses four bytes, then you could inspect a[99] using SubStr( oStruct:cData, 99 * 4, 4 ).

Please also try 98 * 4 and 100 * 4

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Accessing a Delphi DLL function.
Posted: Fri Oct 26, 2007 12:54 PM

Antonio,

Ok, I am lost. I really don't understand how we are connecting to this dll.

I guess my main question is ... are we accessing the dll correctly and getting the correct response ?

I don't want to spend $129.00 if it will not work with Fivewin :?

Thanks,
Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Accessing a Delphi DLL function.
Posted: Fri Oct 26, 2007 04:06 PM

Jeff,

The DLL expects an array of 128 long numbers (a long number uses 4 bytes = 32 bits).

Instead of using 128 struct members, we are using one single string that has 128 * 4 bytes.

The DLL is being accessed as the MessageBox() is shown, though they show a [99], and according to our test they are changing the first long (SubStr( oStruct:cData, 1, 4 ) ) of the array, not the 99.

Could you please ask them about this ? Could they confirm you that they are modifying the 99 element of the array instead of the first one ?

regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Accessing a Delphi DLL function.
Posted: Sat Oct 27, 2007 12:04 AM

Hi Antonio,

Here is the reply:

Yes, in the DLL we change a[99] only, a[0] remains the same.

We've compiled a test application (using the code from our C.txt sample), and placed this to the TestDLL.zip at the same address, please download it.
By this application you can set a[0] value before the DLL function call ( = 0 by default), click the button to call DLL, and then see both a[0] and a[99] result values.
If a[0] is equal to 0, a[1] = 1 ... a[127] = 127 before the function call, after the function call a[99] would be equal to 8300.

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Accessing a Delphi DLL function.
Posted: Sat Oct 27, 2007 07:39 AM
Jeff,

Ok, here you having it working fine. I redesigned it in a total different way:
#include "FiveWin.ch" 

function Main() 

   local cArray := FillArray()

   MsgInfo( A99( cArray ) )

   TestFunc1( cArray ) 

   MsgInfo( A99( cArray ) )
   
return nil 

DLL FUNCTION TESTFUNC1( pValues AS LPSTR ) AS BOOL PASCAL ;
FROM "TestFunc1" LIB "TestLib12.dll" 

#pragma BEGINDUMP

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

HB_FUNC( FILLARRAY )
{
   LONG a[ 128 ];
   int i;
   
   for( i = 0; i < 128; i++ )
      a[ i ] = i;
      
   hb_retclen( ( char * ) a, 128 * sizeof( LONG ) );
}      

HB_FUNC( A99 )
{
   LONG * a =  ( LONG * ) hb_parc( 1 );
   
   hb_retnl( a[ 99 ] );
}   
   
#pragma ENDDUMP
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 933
Joined: Sun Oct 09, 2005 01:05 PM
Accessing a Delphi DLL function.
Posted: Tue Oct 30, 2007 10:00 AM

Thanks for all the help Antonio.

I am going to buy the software today.

I will let you know you well it works.

Jeff

Thanks,

Jeff Barnes



(FWH 16.11, xHarbour 1.2.3, Bcc730)
Posts: 44158
Joined: Thu Oct 06, 2005 05:47 PM
Accessing a Delphi DLL function.
Posted: Tue Oct 30, 2007 10:07 AM

Jeff,

You are welcome,

IMO it will work fine :-)

regards, saludos

Antonio Linares
www.fivetechsoft.com

Continue the discussion