Has anyone successfully used GetMates Method from (IComponent2)? I have an array of the components and I am trying to move through the array of components and get the mates from each component. The code I have compiles and runs but when I watch the output it shows a safearray that contains bad pointers. I have tried many different things but to no avail. I think my problem is with the Variants and the SafeArrays which I do not completely understand.
Code:
IComponent2** componentArray = NULL;
componentArray = new IComponent2 * [componentCount];
swAssemDoc->IGetComponents(false, componentCount, componentArray);
VARIANT compMates;
SAFEARRAY* pSafeArrayOfMates = NULL;
for(long i = 0; i < componentCount; i++){
CComBSTR sComponentName(L"");
componentArray[i]->get_Name(&sComponentName);
componentArray[i]->GetMates(&compMates);
pSafeArrayOfMates = V_ARRAY(&compMates);
}
delete [] componentArray;
swAssemDoc.Release();
}
Thanks,
Eric O.