开发者

Marshal void* to array<byte>^

开发者 https://www.devze.com 2023-01-20 10:27 出处:网络
I am looking to write a void* buffer to a MemoryStream in a C++/CLI. As I don\'t think this is possible dire开发者_如何学运维ctly, alternatively I would like to convert this buffer to an array<byte

I am looking to write a void* buffer to a MemoryStream in a C++/CLI. As I don't think this is possible dire开发者_如何学运维ctly, alternatively I would like to convert this buffer to an array<byte>^ in order to be able to call Stream.Write(). I've looked at Marshal but then I am having trouble coverting void* to System::IntPtr. Any help is appreciated.


I am having trouble coverting void* to System::IntPtr. Any help is appreciated.

You can use the IntPtr constructor which takes a void*:

void* voidPointer = GetTheVoidPointer();
System::IntPtr intPointer(voidPointer);
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号