while ( NS_SUCCEEDED( rv ) && (NS_OK != components->IsDone()) ) { nsCOMPtr<nsISupports> base;
while ( NS_SUCCEEDED( rv ) && !components->IsDone() ) { nsISupports *base;
nsAppShellService::EnumerateComponents( EnumeratorMemberFunction function ) {    nsresult rv;    nsRegistryKey key;    nsCOMPtr<nsIEnumerator> components;    const char *failed = "GetService";    nsCOMPtr<nsIRegistry> registry =              do_GetService(NS_REGISTRY_CONTRACTID, &rv);    if ( NS_SUCCEEDED(rv)          &&         ( failed = "Open" )         &&         NS_SUCCEEDED( ( rv = registry->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry) ) )         &&         ( failed = "GetSubtree" )         &&         NS_SUCCEEDED( ( rv = registry->GetSubtree( nsIRegistry::Common,                                                    NS_IAPPSHELLCOMPONENT_KEY,                                                    &key ) ) )         &&         ( failed = "EnumerateSubtrees" )         &&         NS_SUCCEEDED( ( rv = registry->EnumerateSubtrees( key,                                               getter_AddRefs(components )) ) )         &&         ( failed = "First" )         &&         NS_SUCCEEDED( ( rv = components->First() ) ) ) {        // Enumerate all subtrees        while ( NS_SUCCEEDED( rv ) && (NS_OK != components->IsDone()) ) {            nsCOMPtr<nsISupports> base;                        rv = components->CurrentItem( getter_AddRefs(base) );            if ( NS_SUCCEEDED( rv ) ) {                // Get specific interface.                nsCOMPtr<nsIRegistryNode> node;                nsIID nodeIID = NS_IREGISTRYNODE_IID;                rv = base->QueryInterface( nodeIID,                                           (void**)getter_AddRefs(node) );                // Test that result.                if ( NS_SUCCEEDED( rv ) ) {                    // Get node name.                    char *name;                    rv = node->GetNameUTF8( &name );                    if ( NS_SUCCEEDED( rv ) ) {                        // If this is a CID of a component; apply function to it.                        nsCID cid;                        if ( cid.Parse( name ) ) {                            (this->*function)( cid );                        } else {                            // Not a valid CID, ignore it.                        }                    } else {                        // Unable to get subkey name, ignore it.                    }                    nsCRT::free(name);                } else {                    // Unable to convert item to registry node, ignore it.                }            } else {                // Unable to get current item, ignore it.            }            // Go on to next component, if this fails, we quit.            rv = components->Next();        }    } else {        // Unable to set up for subkey enumeration.        #ifdef NS_DEBUG            printf( "Unable to enumerator app shell components, %s rv=0x%08X\n",                    failed, (int)rv );        #endif    }    return;}