Task:
Application written in Delphi accepts a structure (record in terms of Delphi) of three fields. I can send the pointer of this structure using SendMessage (Win32 API) function.
So a question is:
How to maintain certain structure representation in memory for Delphi in terms of Delphi?
It has type
PWPModPostData = ^ TWPModPostData;
TWPModPostData = record
DataType: Integer;
Data: PChar;
Next: PWPModPostData;
end;
How to define it in C? I mean, is there any hidden or service fields in Delphi structures?
No, there are no hidden fields, and Delphi records and C structs can be mapped to each other 1:1, with a few caveats:
Don’t use any data type C doesn’t
understand. This includes objects,
dynamic arrays, and Delphi strings.
C and Delphi sometimes have different
ideas about how to byte-align fields.
Test your records and verify that
they work on the C side. If they
don’t, try using packed record
instead of record.
When passing a pointer to a record
from C to Delphi or vice versa, make
sure that the side receiving it
doesn’t try to free or reallocate the
memory. It belongs to the memory
manager that created it.