如何构建一个指向VARIANT的指针的SAFEARRAY? [英] How to build a SAFEARRAY of pointers to VARIANTs?
问题描述
我试图使用COM组件与以下方法:
HRESULT _stdcall Run(
[ in] SAFEARRAY(BSTR)paramNames,
[in] SAFEARRAY(VARIANT *)paramValues
);
如何在C / C ++中创建paramValues数组?
<添加到上面的答案供以后的读者参考:
在IDL中,
SAFEARRAY(...)
意味着指向数组描述符的指针。 但是在C ++中,
SAFEARRAY
表示数组描述符。 所以IDL的
SAFEARRAY(...)
真的是C ++的 SAFEARRAY *
。这让我困惑不解。 为了使事情更有趣,VB总是通过引用传递数组。所以VB的
()As Long
是 SAFEARRAY< int32_t> **
在C ++中。 (我不知道是否实际上有一个常用的头,允许你指定类型作为模板参数,但我插入它为了清楚。) I'm trying to use a COM component with the following method:
HRESULT _stdcall Run(
[in] SAFEARRAY(BSTR) paramNames,
[in] SAFEARRAY(VARIANT *) paramValues
);
How can I create in C/C++ the paramValues array?
Adding to the answers above for reference by future readers:
In IDL, SAFEARRAY(...)
means a pointer to an array descriptor.
But in C++, SAFEARRAY
means an array descriptor.
So IDL's SAFEARRAY(...)
is really C++'s SAFEARRAY *
. This confused me to no end.
To make things even more interesting, VB always passes arrays by reference. So VB's () As Long
is SAFEARRAY<int32_t> **
in C++. (I don't know if there actually is a commonly used header that allows you to specify the type as a template parameter, but I inserted it for clarity.)
这篇关于如何构建一个指向VARIANT的指针的SAFEARRAY?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!