佚名通过本文主要向大家介绍了27bao.com邪恶动态图,27bao.com长动态图,27bao.com动态图,m.27bao.com动态图,9b9k.com动态图片等相关知识,希望对您有所帮助,也希望大家支持linkedu.com www.linkedu.com
问题: 关于COM中的动态数组,谢谢!
描述:
解决方案1:
描述:
在接口中传递自定义结构体的数组
不使用SafeArray 是否可以解决。
COM客户是托管.net程序
HRESULT GetArray([out]LONG* pSizeArray,[out,size_is(*pSizeArray)]LONG array[]);
为什么这样的定义在托管.Net中会把数组参数变为 out int array而不是 out int array[];
谢谢!
解决方案1:
如果是传递单个的自定义结构不用安全数组。要是传递自定义结构数组的话好像就得用安全数组来传递了。自定义结构要在IDL文件中声明。
解决方案2: 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.