Just use byte[]
:
[DllImport EntryPoint="myfunc"]
public extern static void MyFunc(byte[]);
byte[] apData = new byte[3];
MyFunc(apData);
سؤال
I have this code in C++
BYTE * apData[3]
How to convert it to C# ? ( I'm using DllImport )
المحلول
Just use byte[]
:
[DllImport EntryPoint="myfunc"]
public extern static void MyFunc(byte[]);
byte[] apData = new byte[3];
MyFunc(apData);
نصائح أخرى
That is an array of length 3, of pointer to BYTE
.
Under the assumption that this appears in a struct it is declared like this:
[MarshalAs(UnmanagedType.ByValArray, SizeConst=3)]
IntPtr[] apData;
Alternatively, if the array is passed as a parameter, declare that parameter like this:
[MarshalAs(UnmanagedType.LPArray, SizeConst=3)]
IntPtr[] apData
You can use a raw pointer
[System.Runtime.InteropServices.DllImportAttribute("<Unknown>", EntryPoint="fun")]
public static extern void fun(System.IntPtr byte_array) ;
just use DLLImport as shown below
[DllImport EntryPoint="func"]
public extern static void Func(byte[]);
byte[] apData = new byte[3];