Accessing a Delphi DLL function.

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

Post by Antonio Linares »

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
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

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 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

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
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

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 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Jeff,

Ok, here you having it working fine. I redesigned it in a total different way:

Code: Select all

#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
User avatar
Jeff Barnes
Posts: 912
Joined: Sun Oct 09, 2005 1:05 pm
Location: Ontario, Canada
Contact:

Post by Jeff Barnes »

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 12.01, xHarbour 1.2.1, Bcc582)
User avatar
Antonio Linares
Site Admin
Posts: 37481
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain
Contact:

Post by Antonio Linares »

Jeff,

You are welcome,

IMO it will work fine :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Post Reply