Board index » delphi » Thunking to 32 bits

Thunking to 32 bits

I use a 16 bit dll driver written in C which accesses a large
database. This works fine with Delphi 1. I have tried  to thunk over
to Delphi 2, with partial success. I am using the method from Dephi
Magazine. The data structure is as follows:
     type
        SRecord = Record
          MM,DD,YY:     integer;
          a,b,c,d:            single;
          e:                     longint;
          f:                      char;
     end;
I can see that the first three integers are being read correctly in
the first record, but all bets are off as soon as the first single is
accessed.  As far as I can determine, single is the same size in
Delphi 1 and 2.  Anybody had this problem?  Do I need to translate the
singles somehow?

Thanks, Jim.

 

Re:Thunking to 32 bits


Quote
James A Whelan wrote:

> I use a 16 bit dll driver written in C which accesses a large
> database. This works fine with Delphi 1. I have tried  to thunk over
> to Delphi 2, with partial success. I am using the method from Dephi
> Magazine. The data structure is as follows:
>      type
>         SRecord = Record
>           MM,DD,YY:     integer;
>           a,b,c,d:            single;
>           e:                     longint;
>           f:                      char;
>      end;
> I can see that the first three integers are being read correctly in
> the first record, but all bets are off as soon as the first single is
> accessed.  As far as I can determine, single is the same size in
> Delphi 1 and 2.  Anybody had this problem?  Do I need to translate the
> singles somehow?

> Thanks, Jim.

Are you sure the integers are being read correctly?  An integer
in D1 is 16 bits....in D2 it is 32 bits.  When I did my
thunking I defined   Integer16 = SmallInt   in D2.  I use
Integer16 when accessing any ints from 16-bit DLLs.

--
Michael Heacock         "Hail hail the lucky ones,
Praxis Technical Group   I refer to those in love"
Nanaimo BC Canada                -- Eddie Vedder

Re:Thunking to 32 bits


Quote
James A Whelan wrote:

> I use a 16 bit dll driver written in C which accesses a large
> database. This works fine with Delphi 1. I have tried  to thunk over
> to Delphi 2, with partial success. I am using the method from Dephi
> Magazine. The data structure is as follows:
>      type
>         SRecord = Record
>           MM,DD,YY:     integer;
>           a,b,c,d:            single;
>           e:                     longint;
>           f:                      char;
>      end;
> I can see that the first three integers are being read correctly in
> the first record, but all bets are off as soon as the first single is
> accessed.  As far as I can determine, single is the same size in
> Delphi 1 and 2.  Anybody had this problem?  Do I need to translate the
> singles somehow?

> Thanks, Jim.

Try using "packed record", like this:
type
        SRecord = packed record
                ...
        end;

/David Sandstr?m

Re:Thunking to 32 bits


Quote
David Sandstr?m <svph9...@informatik.umu.se> wrote:
>James A Whelan wrote:

>> I use a 16 bit dll driver written in C which accesses a large
>> database. This works fine with Delphi 1. I have tried  to thunk over
>> to Delphi 2, with partial success. I am using the method from Dephi
>> Magazine. The data structure is as follows:
>>      type
>>         SRecord = Record
>>           MM,DD,YY:     integer;
>>           a,b,c,d:            single;
>>           e:                     longint;
>>           f:                      char;
>>      end;
>> I can see that the first three integers are being read correctly in
>> the first record, but all bets are off as soon as the first single is
>> accessed.  As far as I can determine, single is the same size in
>> Delphi 1 and 2.  Anybody had this problem?  Do I need to translate the
>> singles somehow?

>> Thanks, Jim.

>Try using "packed record", like this:
>type
>    SRecord = packed record
>            ...
>    end;

>/David Sandstr?m

David:
Packed does the trick. Thanks a lot.
-Jim

Other Threads