C# IntPtr转换为Byte[]
[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[]的更多相关文章
- 网络流转换为Byte数组
/// <summary> /// 网络流转换为Byte数组 /// </summary> /// <param name="stream">& ...
- 16进制字符串转换为byte数组
/// <summary> /// 16进制字符转换为byte数组 /// </summary> /// <param name="hexString" ...
- C#中使用Buffer.BlockCopy()方法将string转换为byte array的方法:
public static void BlockCopy(Array src, int srcOffset, Array dst, int dstOffset, int count); 将指定数目的字 ...
- C# 对象转换为byte[] ,byte[]还原对象
/// <summary> /// 将一个object对象序列化,返回一个byte[] /// </summary> /// <param name ...
- C#程序中将图片转换为byte数组,并将byte数组转换为图片
/// <summary> /// 将图片以二进制流 /// </summary> /// <param name="path"></pa ...
- java 读取本地文件并转换为byte数组
private byte[] InputStream2ByteArray(String filePath) throws IOException { InputStream in = new File ...
- [C#] 如何把void*转换为byte[]
一般来说,C#库的对外接口应该提供byte[]这样比较容易用的接口,而不应该提供裸的void* 但是有些库确实是这么封装的.那么就有一个如何转换的问题.MSDN推荐的转换方式是使用UnmanagedM ...
- C# byte[]、struct、intptr等的相互转换
1.struct byte[]互相转换 //struct转换为byte[] public static byte[] StructToBytes(object structObj) { int siz ...
- c#中char、string转换为十六进制byte的浅析
问题引出: string转换为byte(十六进制) static void Main(string[] args) { "; byte[] b = Encoding.Default.GetB ...
随机推荐
- [POJ3468] A Simple Problem with Integers (Treap)
题目链接:http://poj.org/problem?id=3468 这题是线段树的题,拿来学习treap. 不旋转的treap. #include <cstdio> #include ...
- WPF 绑定的校验
为进行校验,必须准备一个RangeValidationRule类,该类继承自ValidationRule 该类实现如下: class RangeValidationRule : ValidationR ...
- 记录Castle ActiveRecord访问Sqlite的配置
1.ActiveRecord配置文件ARConfig.xml,并将配置文件的“生成操作”改成“嵌入的资源” <?xml version=; i < ; i++) { ...
- 【转载】彻底卸载MYSQL的方法
1.控制面板里的增加删除程序内进行删除 2.删除MySQL文件夹下的my.ini文件,如果备份好,可以直接将文件夹全部删除 3.开始->运行-> regedit 看看注册表里这几个地方删除 ...
- zhizhensuibi---Source aplikasi database dengan delphi7
Install INDY 10 dari : G:\D\My\ Source \DELPHI\ DELPHI7 \Indy10\ : 从上面打开第3行---保存---运行SRC http://sp.j ...
- linux查看父子进程
python多进程代码 http://blog.csdn.net/yfkiss/article/details/6729364 Linux下多线程查看工具(pstree.ps.pstack) tes ...
- Delphi编写DLL供C#调用的实例
Delphi中编写的Dll: library TestDLL; { Important note about DLL memory management: ShareMem must be the f ...
- JS判断input按了回车键
参考代码如下: <input type="textbox" id="textbox1" onkeypress="CheckInfo" ...
- 改变BootStrap主题颜色
摘自:http://www.asp.net/visual-studio/overview/2013/creating-web-projects-in-visual-studio#bootstrap Y ...
- delphi中break,continue, exit,abort, halt, runerror的异同
delphi中表示跳出的有break,continue, exit,abort, halt, runerror. 1.break 强制退出循环(只能放在循环中),用于从For语句,while语句或re ...