host-2008

导航

2014年1月20日

C#中char[]与string之间的转换

摘要: string 转换成 Char[] string ss = "abcdefg"; char[] cc = ss.ToCharArray();Char[] 转换成string string s = new string(cc);此外,byte[] 与 string 之间的装换 byte[] bb = Encoding.UTF8.GetBytes(ss); string s = Encoding.UTF8.GetString(bb);下面我们利用 StringBuilder 来进行数组 与 string 间的转换 , 很简单,代码如下using System.Text;Stri 阅读全文

posted @ 2014-01-20 16:33 夜来风雨香 阅读(336) 评论(0) 推荐(0) 编辑

c#调用C++DLL参数对应

摘要: //C++中的DLL函数原型為 //extern “C” __declspec(dllexport) bool 方法名一(const char* 变量名1, unsigned char* 变量名2) //extern “C” __declspec(dllexport) bool 方法名二(const unsigned char* 变量名1, char* 变量名2) //c++:HANDLE(void *) —- c#:System.IntPtr //c++:Byte(unsigned char) —- c#:System.Byte //c++:SHORT(short) —- c#:System 阅读全文

posted @ 2014-01-20 16:32 夜来风雨香 阅读(443) 评论(0) 推荐(0) 编辑

解决:对 PInvoke 函数的调用导致堆栈不对称问题 <转载>

摘要: 问题描述: 在使用托管代码调用非托管代码时,发生“对 PInvoke 函数“UseTwiHikVisionDllTest!UseTwiHikVisionDllTest.TwiHikVision::GetFirstPic”的调用导致堆栈不对称。原因可能是托管的 PInvoke 签名与非托管的目标签名不匹配。请检查 PInvoke 签名的调用约定和参数与非托管的目标签名是否匹配。”解决方法: 添加属性:CallingConvention=CallingConvention.Cdecl如: [DllImport("TwiHikVision.dll", EntryPoint=&qu 阅读全文

posted @ 2014-01-20 11:56 夜来风雨香 阅读(830) 评论(0) 推荐(0) 编辑