Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/154.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/arrays/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 在com中创建字符串数组_C++_Arrays_Visual C++_Com_Mfc - Fatal编程技术网

C++ 在com中创建字符串数组

C++ 在com中创建字符串数组,c++,arrays,visual-c++,com,mfc,C++,Arrays,Visual C++,Com,Mfc,我是com的新手,对MFC有一点了解,我们可以使用CStringArray来收集字符串。在下面的com组件示例中,我对如何在com中使用字符串感到困惑。 下面是一个例子, 我正在开发com组件,也在使用它,在我的com组件中,以下是功能要求, 从xml文件中读取二维数组并将其转储到一个公共数组中,如 _bstr_t bstrMember1Name,bstrMember2Name; IEachData portsDataNode; while(portsDataNo

我是com的新手,对MFC有一点了解,我们可以使用CStringArray来收集字符串。在下面的com组件示例中,我对如何在com中使用字符串感到困惑。 下面是一个例子, 我正在开发com组件,也在使用它,在我的com组件中,以下是功能要求, 从xml文件中读取二维数组并将其转储到一个公共数组中,如

_bstr_t          bstrMember1Name,bstrMember2Name;
IEachData        portsDataNode;
while(portsDataNode = CollectionOfData->NextData())
{
    if (!GetStringAttribute(portsDataNode, _T("Member1"), bstrMember1Name))
    {
            hr = E_FAIL;
    }
    if (!GetStringAttribute(portsDataNode, _T("Member2"), bstrMember2Name))
    {
            hr = E_FAIL;
    }
 }

这是函数体,因为我从一个com公司调用中获取Member1和Member2作为返回类型,但我需要收集每个和值。那么函数的参数是什么?我如何将Member1和Member2收集到单个变量中???

对不起。我没有那样理解你的问题。如果要返回数据集合(比如数组),则需要一个安全数组。因此,请使用SafeArrayCreate。如果我不仅仅是COM,而且您需要自动化,那么您必须使用变体安全阵列。可以跨COM边界传递SAFEARRAY。BSTR的安全阵列是可能的。还有多维数组

对不起。我没有那样理解你的问题。如果要返回数据集合(比如数组),则需要一个安全数组。因此,请使用SafeArrayCreate。如果我不仅仅是COM,而且您需要自动化,那么您必须使用变体安全阵列。可以跨COM边界传递SAFEARRAY。BSTR的安全阵列是可能的。还有多维数组