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.)