Always use C ++ const char * or char *, not std :: string.
Also keep in mind that char in C ++ is sbyte in C # and unsigned char is a byte in C #.
It is advisable to use unsafe code when working with DllImport.
[DllImport("zip4_w32.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "z4LLkGetKeySTD", ExactSpelling = false)] private extern static sbyte* or byte* z4LLkGetKeySTD(); void foo() { string res = new string(z4LLkGetKeySTD()); }
Robert
source share