I have a 3rd party DLL containing the following function:
SDK_API FunctionInQuestion(char* name, myStruct table[row][column]);
I'm pretty sure this function WILL modify myStruct table[row][column].
I need to call this from .net, here is how I tried (the used language is VB.NET, but if you know how to do it in C# thats not a problem, I'm pretty sure the principles are the same)
<System.Runtime.InteropServices.DllImportAttribute("dllinquestion.dll", EntryPoint:="FunctionInQuestion", CallingConvention:=Runtime.InteropServices.CallingConvention.Cdecl)> _
Public Shared Function FunctionInQuestion(ByVal name As System.Text.StringBuilder, ByRef table()() As myStruct) As Integer
End Function
myStruct C:
typedef struct
{
unsigned short int x;
unsigned short int y;
}myStruct;
myStruct .net:
<Runtime.InteropServices.StructLayout(Runtime.InteropServices.LayoutKind.Sequential)> _
Public Structure myStruct
Public x As UShort
Public y As UShort
End Structure
I've been Googling/searching Stackoverflow for a couple hours now and tried every 'solution' thus far, but I haven't been able to make it work. Please if you redirect/vote to close the question, I beg you to first look at the other question. If it's really a marshalling of a 2D struct array AND you are sure the question contains an answer, then please by all means close this, all the better.
myStruct table[][column]. You'd just got a row major array. The elements are 0,0, 0,1, ..., 0,column-1, 1,0, 1,1, ..., 1,column-1, 2,0 and so on.