, : # DLL , char * . , . , , - , .. .
, DLL , [] 2 , :
private const string MYDLL = @"my.dll";
[DllImport(MYDLL, CallingConvention = CallingConvention.StdCall, CharSet = CharSet.Auto)]
public static extern int DataBlockDownload([MarshalAs(UnmanagedType.U4)] int A, [MarshalAs(UnmanagedType.LPArray, SizeConst = 2048)] byte[] B, [MarshalAs(UnmanagedType.U4)] int C);
public delegate int DDataBlockCallback([MarshalAs(UnmanagedType.U4)] int A, [MarshalAs(UnmanagedType.LPArray, SizeConst = 2048)] byte[] B, [MarshalAs(UnmanagedType.U4)] int C);
, , char, .
You do not say what you are doing with your char * data if it is included in your C ++ code as a parameter or C ++ code passes it back to the managed world. Read the C # ref and out keywords as ways to avoid the char * type and the unsafe modifier.
With a little Googling from this, you can figure it out.
source
share