将 void* 封送至数组^

发布于 2024-09-27 08:18:54 字数 277 浏览 0 评论 0原文

我希望在 C++/CLI 中将 void* 缓冲区写入 MemoryStream 中。因为我认为这不可能直接实现,所以我想将此缓冲区转换为 array^ 以便能够调用 Stream.Write()代码>.我查看了 Marshal,但后来我在将 void* 转换为 System::IntPtr 时遇到了麻烦。任何帮助表示赞赏。

I am looking to write a void* buffer to a MemoryStream in a C++/CLI. As I don't think this is possible directly, 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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

韬韬不绝 2024-10-04 08:18:54

我在将 void* 转换为 System::IntPtr 时遇到问题。如有任何帮助,我们将不胜感激。

您可以使用 IntPtr 构造函数,该构造函数采用 void*< /a>:

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

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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文