I need to include a .dll which contains the following C/C++ function prototype and struct definition:
typedef struct
{
unsigned short us1;
unsigned short us2;
unsigned short data[16];
} myStruct;
int myFunc(myStruct *MYSTRUCT);
To use this Function i created a new Class:
static class DLL
{
public struct MyStruct
{
public ushort us1;
public ushort us2;
public ushort[] data;
public PDPORT(ushort[] temp1, ushort temp2, ushort temp3)
{
us1 = temp2;
us2 = temp3;
data = temp1;
}
};
[DllImport("PDL65DLL.dll")]
public static extern int mvb_PutPort(ref MyStruct CommData);
}
In my main class I initiliaze the struct variable and call the Function like that:
DLL.MyStruct communicationData = new DLL.MyStruct(new ushort[16], new ushort(), new ushort());
DLL.MyFunc( ref communicationData);
However, this does not seem to work. The Function is passing something but not the right values, I suggest it is something with the pointer usage. Maybe a struct* is not the same as ref struct... Can someone explain what the problem is?
myFunc, and theexternismvb_PutPortwith nothing to tell it the new name; is that just a copy/paste thing? because: that also won't make things happy