BernardSAS
April 9th, 2003, 12:28 PM
i'm writing an add-in for visual .NET in C++, and i have a problem to access elements in safearray of BSTR.
I use the following code :
VARIANT varNames;
pGroup->get_FileNames (&varNames);
if ((varNames.vt & VT_ARRAY) && (varNames.vt & VT_BSTR))
{
SAFEARRAY *pSA = NULL;
if (varNames.vt & VT_BYREF)
pSA = *(varNames.pparray);
else
pSA = varNames.parray;
if (pSA != NULL)
{
BSTR *pStrArray;
SafeArrayAccessData (pSA, (void**) &pStrArray);
for (long l = 0; l < pSA->rgsabound->cElements; l ++)
{
CString str (pStrArray[l]);
TRACE (" l %ld %s\n", l, str);
}
SafeArrayUnaccessData (pSA);
}
}
the problem is that the displayed strings are empty.
if someone can tell me what i've done wrong :confused:
I use the following code :
VARIANT varNames;
pGroup->get_FileNames (&varNames);
if ((varNames.vt & VT_ARRAY) && (varNames.vt & VT_BSTR))
{
SAFEARRAY *pSA = NULL;
if (varNames.vt & VT_BYREF)
pSA = *(varNames.pparray);
else
pSA = varNames.parray;
if (pSA != NULL)
{
BSTR *pStrArray;
SafeArrayAccessData (pSA, (void**) &pStrArray);
for (long l = 0; l < pSA->rgsabound->cElements; l ++)
{
CString str (pStrArray[l]);
TRACE (" l %ld %s\n", l, str);
}
SafeArrayUnaccessData (pSA);
}
}
the problem is that the displayed strings are empty.
if someone can tell me what i've done wrong :confused: