在接口中传递自定义结构体的数组不使用SafeArray 是否可以解决。
COM客户是托管.net程序
HRESULT GetArray([out]LONG* pSizeArray,[out,size_is(*pSizeArray)]LONG array[]);
为什么这样的定义在托管.Net中会把数组参数变为 out int array而不是 out int array[];
谢谢!

解决方案 »

  1.   

    No, managed arrays have to be allocated from the GC heap. You need a wrapper class written in C++/CLI.What you really should be concerned about is to free the memory correctly. Since you allocate with new in C++, you should provide a function that deletes the array memory as well. 
      

  2.   

    如果是传递单个的自定义结构不用安全数组。要是传递自定义结构数组的话好像就得用安全数组来传递了。自定义结构要在IDL文件中声明。
      

  3.   

    能给个SafeArray使用的例子吗?
    谢谢!