C#如何从IntPtr获取Byte [] [英] C# how to get Byte[] from IntPtr

查看:212
本文介绍了C#如何从IntPtr获取Byte []的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个具有委托的.dll(不是我自己的).该委托回调函数为:
"CallBackFN(ushort opCOde, IntPtr有效负载,uint大小,uint localIP)"

I have a .dll(not my own) that has a delegate. This delegate Callback function is:
"CallBackFN(ushort opCOde, IntPtr payload, uint size, uint localIP)"

如何将IntPtr转换为Byte []?我认为有效负载实际上是Byte [].如果不是Byte []而是其他东西,我会丢失一些数据吗?

How can i convert IntPtr to Byte[]? I think that payload is actually Byte[]. If it's not Byte[] and it's something else would i lose some data?

推荐答案

您是否看过Marshal.Copy?

Have you looked into Marshal.Copy?

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

这篇关于C#如何从IntPtr获取Byte []的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆