I have the following code:
The returned variant contains a SafeArray of IDispatch pointers. I have verified that the count of the SafeArray is correct, but the IDispatch pointers are all NULL.Code:// Get all of the children components from this m_Component object _variant_t componentChildren = pComponent->GetChildren();
I extract the array elements like below:
The pChildren[i] causes an access violation error.Code:if ((componentChildren.vt == VT_EMPTY) || (V_VT(&componentChildren) == VT_NULL)) // Error - array is empty or null return 0; SAFEARRAY* psa = V_ARRAY(&componentChildren); HRESULT hres = SafeArrayAccessData(psa, (void **)pChildren); long highIndex; SafeArrayGetUBound(psa, 1, &highIndex); // Get index number of highest array element // The array range is from 0 to highIndex long childrenCount = highIndex + 1; // Actual # of array elements is highIndex + 1 if(pChildren) { // Recursively traverse the children for (int i = 0; i < childrenCount; i++) // For each child component { TraverseChildren(RecurseLevel, pChildren[i]); } }
What could be the probable reasons for this. Please help I am stuck in this.




Reply With Quote