1、传入单字节ANSI字符
[DllImport("hostIO", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern int initHost([MarshalAs(UnmanagedType.LPStr)] string host);
2、传入双字节Unicode字符
[DllImport("hostIO", CharSet = CharSet.Ansi, CallingConvention = CallingConvention.Cdecl)]
public static extern int initHost([MarshalAs(UnmanagedType.LPWStr)] string host);
原文地址:http://blog.csdn.net/wuliao009/article/details/41079179