110,533
社区成员
发帖
与我相关
我的任务
分享
[DllImport(@"C:\Windows\System32\Keys-windows.dll")]
public static extern IntPtr CMd5_data(string str);
[DllImport("rython_share", EntryPoint = "DBAR_CompValue", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.StdCall)]
[DllImport("xxx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CMd5_data([MarshalAs(UnmanagedType.LPStr)] StringBuilder sb);
[DllImport("xxx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern string CMd5_data([MarshalAs(UnmanagedType.LPStr)] StringBuilder sb);
如果传入参数不需要修改,就用下面两个。
[DllImport("xxx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern IntPtr CMd5_data([MarshalAs(UnmanagedType.LPStr)] string sb);
[DllImport("xxx.dll", CallingConvention = CallingConvention.Cdecl)]
public static extern string CMd5_data([MarshalAs(UnmanagedType.LPStr)] string sb);
返回IntPtr和String是有区别的,依赖于你返回指向所指向内存的申请方式。