【问题标题】:interoperatability Cpluspluss_CLI_ManagedArray <--> Array互操作性 Cplusplus CLI_ManagedArray <--> Array
【发布时间】:2009-06-17 16:33:14
【问题描述】:

如何转换 c++/CLI 数组和原生 c++ 数组之间的互操作性,反之亦然。

数组^ Cpluspluss_CLI_ManagedArray;

unsigned char* UnmanagedArray;

我找到了 System::Runtime::InteropServices::Marshal; (IntPtr) 对于像我这样的初学者来说,有很多信息(对 CLI)所以我不确定该使用哪个。

谢谢

拉吉

【问题讨论】:

    标签: c++-cli interop clr


    【解决方案1】:

    // 非托管到托管...

    IntPtr ptr((unsigned char*)UnmanagedArray);

    数组^Cpluspluss_CLI_ManagedArray = gcnew 数组(UnmanagedArrayLength);

    Marshal::Copy(ptr, Cpluspluss_CLI_ManagedArray, 0, UnmanagedArrayLength);

    // 非托管到托管... See this Post

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-08-17
      • 1970-01-01
      • 2021-08-28
      • 2021-07-31
      • 2010-12-27
      • 2019-07-15
      • 2017-07-03
      • 1970-01-01
      相关资源
      最近更新 更多