如何构建一个指向VARIANT的指针的SAFEARRAY? [英] How to build a SAFEARRAY of pointers to VARIANTs?

查看:337
本文介绍了如何构建一个指向VARIANT的指针的SAFEARRAY?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆