鉴于此C API声明如何将其导入C#?
const char* _stdcall z4LLkGetKeySTD(void);
我已经能够做到这一点:
[DllImport("zip4_w32.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "z4LLkGetKeySTD", ExactSpelling = false)] private extern static const char* z4LLkGetKeySTD();
JaredPar.. 12
试试这个
[DllImport("zip4_w32.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "z4LLkGetKeySTD", ExactSpelling = false)] private extern static IntPtr z4LLkGetKeySTD();
然后,您可以使用Marshal.PtrToStringAnsi()将结果转换为String.您仍然需要使用适当的Marshal.Free*方法释放IntPtr的内存.
试试这个
[DllImport("zip4_w32.dll", CallingConvention = CallingConvention.StdCall, EntryPoint = "z4LLkGetKeySTD", ExactSpelling = false)] private extern static IntPtr z4LLkGetKeySTD();
然后,您可以使用Marshal.PtrToStringAnsi()将结果转换为String.您仍然需要使用适当的Marshal.Free*方法释放IntPtr的内存.