question~ SolidWorks 2005 API: using IGetChildren

I have a question about using IGetChildren in SolidWorks 2005 API in Visual C++ 6.0
Suppose I have an Assembly file containing 3 part files.
I would like to use the IGetChildren function to get the name of each part (component) one by one, using the code below. But after IGetChildren is called, in the pChildren array, only the first element gets the first part. The remaining elements could retrieve nothing.
Would someone figure out why IGetChildren() cannot get all the children (parts) in this case? Many many thanks!
IComponent2** pChildren = NULL; CComQIPtr<IModelDoc2> pModel; CComQIPtr<IConfiguration> pConfiguration; int nChildren, i; if (pModel->IGetActiveConfiguration(&pConfiguration) == S_OK ) {     if ( pConfiguration->IGetRootComponent2(&pRootComponent) == S_OK )     {
        HRESULT hres = pComponent->IGetChildrenCount(&nChildren);         if ( S_OK == hres && nChildren > 0 )         {             pChildren = new IComponent2* [nChildren];             hres = pComponent->IGetChildren(pChildren);             if (S_OK == hres)             {                 for ( i=0; i<nChildren; i++ )                 {                     // code to do tasks like getting name, ...
// but now only OK for the first element!                 }             }         }     } }
Add pictures here
<% if( /^image/.test(type) ){ %>
<% } %>
Add image file
Upload is a website by engineers for engineers. It is not affiliated with any of manufacturers or vendors discussed here. All logos and trade names are the property of their respective owners.