Marshal void * to array <byte> ^ </byte>

时间:2010-10-12 21:32:23

标签: c++-cli marshalling managed-c++

我希望在C ++ / CLI中向void*写一个MemoryStream缓冲区。由于我不认为这是可能的直接,或者我想将此缓冲区转换为array<byte>^,以便能够调用Stream.Write()。我查看了Marshal,但后来我无法将void*转换为System::IntPtr。任何帮助表示赞赏。

1 个答案:

答案 0 :(得分:2)

  

我无法将void *转换为System :: IntPtr。任何帮助表示赞赏。

您可以使用IntPtr constructor which takes a void*

void* voidPointer = GetTheVoidPointer();
System::IntPtr intPointer(voidPointer);
相关问题