Based on the following C++ Header content:
typedef struct {
char myVar[30][50];
}MyStruct;
extern "C" int WINAPI MyFunction(MyStruct *Configuration,int *CfgSize);
I have looked for many examples over the internet but none uses a matrix variable inside a struct array as a parameter.
Can someone please tell me How to consume this function in C#?
In order to marshal this array member you just need to flatten it to the 1500 elements that it represents
[StructLayoutAttribute(LayoutKind.Sequential)]
public struct MyStruct {
/// byte[1500]
[MarshalAsAttribute(UnmanagedType.ByValArray, SizeConst=1500, ArraySubType=UnmanagedType.I1)]
public byte[] myVar;
}
Do make sure to initialize the myVar
array though manually when using in C#
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.