I use the RGiesecke "Uncontrolled Export" package to create a dll from C # that can be called from a Delphi application.
In particular, I want to pass an array of structure arrays.
What I did in C # is
public struct MyVector
{
public float X;
public float Y;
}
[DllExport]
public static void DoStuff([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]
MyVector[] vectors, int count)
{
}
which can then be called from Delphi by doing something like this:
unit MyUnit
interface
type
TVector = array[X..Y] of single;
TVectorCollection = array of TVector;
procedure TDoExternalStuff(const vectors : TVectorCollection; count : integer; stdcall;
procedure DoSomeWork;
implementation
procedure DoSomeWork;
var
vectors : array of TVector;
fDoExternalStuff : TDoExternalStuff;
Handle: THandle;
begin
// omitted: create and fill vectors
Handle := LoadLibrary('MyExport.dll');
@fDoExternalStuff := GetProcAddress(Handle, 'DoStuff');
fDoExternalStuff(vectors, Length(vectors));
end;
end.
However, I really need to make an array of the TVector array . An array of structures that contain the TVector array will also be implemented. But to write
[DllExport]
public static void DoStuff([MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)]
MyVector[][] vectors, int count)
{
}
Does not work with Delphi
...
TVectorCollection = array of array of TVector;
...
procedure DoSomeWork;
var
vectors : array of array of TVector;
fDoExternalStuff : TDoExternalStuff;
Handle: THandle;
begin
Handle := LoadLibrary('MyExport.dll');
@fDoExternalStuff := GetProcAddress(Handle, 'DoStuff');
fDoExternalStuff(vectors, Length(vectors));
end;
And I would also be a little surprised if this happened, since I did not indicate the length of the individual elements of the array without teeth.
Is there a way to configure my DllExport function to marshal this element type?