C#调用C接口字符参数编码的问题解决方法

时间:2014-11-13 16:44:56   收藏:0   阅读:370

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

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!