ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Passing record of records to DLL

Note: You must be registered in order to post a reply.
To register, click here. Registration is FREE!

View 
UserName:
Password:
Format  Bold Italicized Underline  Align Left Centered Align Right  Horizontal Rule  Insert Hyperlink   Browse for an image to attach to your post Browse for a zip to attach to your post Insert Code  Insert Quote Insert List
   
Message 

 

Emoji
Smile [:)] Big Smile [:D] Cool [8D] Blush [:I]
Tongue [:P] Evil [):] Wink [;)] Black Eye [B)]
Frown [:(] Shocked [:0] Angry [:(!] Sleepy [|)]
Kisses [:X] Approve [^] Disapprove [V] Question [?]

 
Check here to subscribe to this topic.
   

T O P I C    R E V I E W
spetric Posted - Dec 16 2016 : 18:49:41
Hi,

I'm trying to set my DLL to work from Delphi and I've encountered a problem.
I have a record which contain 4 other records:

type
  Tpx_RenderData = record
    RenderParams: Tpx_RenderParams;
    SelectionParams: Tpx_SelectionParams;
    DrawParams: Tpx_DrawParams;
    ShadowParams: Tpx_ShadowParams;
  end {Tpx_RenderData};


Now, initializing function should fill this record with initial data.
Here is a function definition:

function speInit(var renderData: Tpx_RenderData): Bool cdecl  {$IFDEF WIN32} stdcall {$ENDIF};
function speInit; external 'libSpEngine.dll';


In main form function is called:

var
  frmMain: TfrmMain;
  renderData: Tpx_RenderData; //(record)
.....
begin
  IEGlobalSettings().AutoFragmentBitmap := False;
  speInit(renderData);
  ....


I've traced DLL and it fills renderData.ShadowParams record with some data,
but after DLL function exits, everything inside renderData.ShadowParams is as before. In C++ everything works ok. In Delphi I'm passing renderData record by reference (var) but nothing happens.

When simple record from Delphi is passed to some DLL, everything is Ok.
I'm obviously missing something when nested records are in the game!?

TIA,
Siniša






1   L A T E S T    R E P L I E S    (Newest First)
spetric Posted - Dec 17 2016 : 15:02:55
Got it!

The problem was in bool (c++, 1 byte) converted to Bool (Delphi, 4 bytes).
The Delphi documentation states that there are 4 boolean types:
Boolean, ByteBool, WordBool, and LongBool. Where the hack that Bool came from?

As Bolean is 1 byte (the same as ByteBool), renaming Bool to Boolean solved the problem, as C++ structure and Delphi record are now of the same size and record/structure fields are filled correctly.