Accessing a Delphi DLL function.

Postby Antonio Linares » Thu Oct 25, 2007 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

Postby Antonio Linares » Thu Oct 25, 2007 6: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Antonio Linares » Fri Oct 26, 2007 4: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
User avatar
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Antonio Linares » Sat Oct 27, 2007 7:39 am

Jeff,

Ok, here you having it working fine. I redesigned it in a total different way:
Code: Select all  Expand view  RUN
#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
Antonio Linares
Site Admin
 
Posts: 42107
Joined: Thu Oct 06, 2005 5:47 pm
Location: Spain

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

Postby Antonio Linares » Tue Oct 30, 2007 10:07 am

Jeff,

You are welcome,

IMO it will work fine :-)
regards, saludos

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

Previous

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: antolin, Google [Bot] and 69 guests