I have a struct defined in a type library imported into both a Delphi 5 and a C# assembly.
[StructLayout(LayoutKind.Sequential, Pack = 1)]
public struct MyStruct
{
public uint a;
public float b;
}
MyStruct = packed record
a: LongWord;
b: Single;
end;
On the Delphi side I have a pointer to a C-style array of said structs which I would like to pass via COM to a C# assembly. Ideally, I'd like this to end up on the c# side as a myStruct[], but I'll take a pointer to a properly marshalled block of memory, the since the structs are all blittable.
Two ways I've tried are
void DoFoo([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] MyStruct[] fooArray, int size);
void DoBar(MyStruct[] barArray, int length);
which after being converted to a type library and imported into delphi are
procedure DoFoo(var fooArray: MyStruct; size: Integer); safecall;
procedure DoBar(barArray: PSafeArray; length: Integer); safecall;
I didn't think safe arrays worked with structs, and the other clearly isn't an array.
Any ideas/links/whatever greatly appreciated.