[DllImport("OpenNetStream.dll")]
public static extern int OpenSDK_Data_GetDevList(IntPtr szAccessToken, int iPageStart, int iPageSize,
ref IntPtr pBuf, ref int iLength); //其中pBuf参数,为返回的一个byte[]数据,现在要将其转换为byte[],然后在转换为string
int size = ;
byte[] managedArray = new byte[size];
Marshal.Copy(pBuf, managedArray, , size); //获得string类型
string json = System.Text.Encoding.Default.GetString(managedArray);

参考:http://stackoverflow.com/questions/5486938/c-sharp-how-to-get-byte-from-intptr

https://msdn.microsoft.com/en-us/library/system.runtime.interopservices.marshal.copy.aspx

C# IntPtr转换为Byte[]的更多相关文章

  1. 网络流转换为Byte数组

    /// <summary> /// 网络流转换为Byte数组 /// </summary> /// <param name="stream">& ...

  2. 16进制字符串转换为byte数组

    /// <summary> /// 16进制字符转换为byte数组 /// </summary> /// <param name="hexString" ...

  3. C#中使用Buffer.BlockCopy()方法将string转换为byte array的方法:

    public static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count); 将指定数目的字 ...

  4. C# 对象转换为byte[] ,byte[]还原对象

    /// <summary>  /// 将一个object对象序列化,返回一个byte[]          /// </summary>  /// <param name ...

  5. C#程序中将图片转换为byte数组,并将byte数组转换为图片

    /// <summary> /// 将图片以二进制流 /// </summary> /// <param name="path"></pa ...

  6. java 读取本地文件并转换为byte数组

    private byte[] InputStream2ByteArray(String filePath) throws IOException { InputStream in = new File ...

  7. [C#] 如何把void*转换为byte[]

    一般来说,C#库的对外接口应该提供byte[]这样比较容易用的接口,而不应该提供裸的void* 但是有些库确实是这么封装的.那么就有一个如何转换的问题.MSDN推荐的转换方式是使用UnmanagedM ...

  8. C# byte[]、struct、intptr等的相互转换

    1.struct byte[]互相转换 //struct转换为byte[] public static byte[] StructToBytes(object structObj) { int siz ...

  9. c#中char、string转换为十六进制byte的浅析

    问题引出: string转换为byte(十六进制) static void Main(string[] args) { "; byte[] b = Encoding.Default.GetB ...

随机推荐

  1. 为什么SqlTransaction.Rollback会抛出SqlException(11,-2)(即SQL超时异常)

    // System.Data.SqlClient.SqlTransaction public override void Rollback() {     if (this.IsYukonPartia ...

  2. Latex感想

    看人家,一个小女生,被导师逼着,首先对电脑方面理解不多,3天时间,latex已经把Paper框架建立起来,我可以说我自愧不如吗?德鲁克<卓有成效的管理者>说的一次干一件事情,<冬吴相 ...

  3. VMware/Microsoft官网查询参加的培训及认证信息

    如果你参加了VMWare的培训,会要求你拿一个已经注册的邮箱加上一个密码在VMware的系统里面登记,这样你就能在VMWARE官网查到注册,并据此你才能申请VMWare的考试认证. 例如下图,路径为 ...

  4. Java中的闪光点:ThreadLocal是线程Thead的局部变量,可替代同步机制的设计,值得学习和研究

    线程局部变量ThreadLocal,是Java支持的一种线程安全机制,目的是解决多线程的并发问题. 具体来讲,就是多个线程访问该实例对象的变量时,该实例对象将其存储为键值对的形式,保证各个线程(键)分 ...

  5. (转)关于URLDownloadToFile下载文件

    转自:http://zhouhaijiang3.blog.163.com/blog/static/43477220200931981322497/ 在下载文件时,下载文件的目录大小写要注意和虚拟目录的 ...

  6. leetcode-【hard】4. Median of Two Sorted Arrays

    题目 There are two sorted arrays nums1 and nums2 of size m and n respectively. Find the median of the ...

  7. 再谈vertical-align与line-height

    每次遇到多个inline-block元素排列的怪异垂直位置的问题的时候都可以通过经验,设置vertical-align来解决,没深入研究过,现在需要分析总结下这个问题. 问题引出 有小鲜肉新做了个页面 ...

  8. VS2013不显示最近打开文件

    首先点击开始在左下角输入"regedit" 右击HKEY_CURRENT_USER,点击查找,输入NoRecentDocsHistory 在右边找到NoRecentDocsHist ...

  9. windows下git识别大小写配置

    默认情况下windows上的Git客户端,在文件名仅发生大小写改变时不会识别,提交后发现,gitlab上的文件名不会发生变化. 解决方法: 编辑 .git 中的config文件, 将 ignoreca ...

  10. sqlserver如何关闭死锁进程.

    1.首先我们需要判断是哪个用户锁住了哪张表. --查询被锁表 select request_session_id spid,OBJECT_NAME(resource_associated_entity ...