rv = reg->OpenDefault();
rv = reg->OpenWellKnownRegistry(nsIRegistry::ApplicationComponentRegistry);
nsresult nsImportService::DoDiscover( void){		if (m_didDiscovery)		return( NS_OK);		if (m_pModules != nsnull)		m_pModules->ClearList();		        nsresult rv;	           	NS_WITH_SERVICE( nsIRegistry, reg, kRegistryCID, &rv);   	if (NS_FAILED(rv)) return rv;   	   	rv = reg->OpenDefault();   	if (NS_FAILED(rv)) return( rv);   		    		nsRegistryKey	modulesKey;	rv = GetImportModulesRegKey( reg, &modulesKey);   	if (NS_FAILED(rv)) return( rv);        // enumerate the modules key        nsIEnumerator *	enumerator;    rv = reg->EnumerateSubtrees( modulesKey, &enumerator);		if (NS_FAILED( rv)) return( rv);	// Go to beginning...	char *pNodeName;	nsIID nodeIID = NS_IREGISTRYNODE_IID;	rv = enumerator->First();	while ( NS_SUCCEEDED(rv) && (NS_OK != enumerator->IsDone())) { 		nsISupports *base;		rv = enumerator->CurrentItem( &base );				if (NS_SUCCEEDED( rv)) {			// Get specific interface.			nsIRegistryNode *node;			rv = base->QueryInterface( nodeIID, (void**)&node);		    if (NS_SUCCEEDED(rv)) {				// Get node name.				pNodeName = nsnull;				rv = node->GetName( &pNodeName);					if (NS_SUCCEEDED( rv) && (pNodeName != nsnull)) {					nsRegistryKey 	key;					rv = reg->GetSubtree( modulesKey, pNodeName, &key);					PR_Free( pNodeName);					if (NS_SUCCEEDED( rv)) {						// get the info we need for this module						char *pClsId = nsnull;						rv = reg->GetString( key, "CLSID", &pClsId);						if (NS_SUCCEEDED( rv) && (pClsId != nsnull)) {							char *pSupports = nsnull;							rv = reg->GetString( key, "Supports", &pSupports);							if (NS_SUCCEEDED( rv) && (pSupports != nsnull)) {								LoadModuleInfo( pClsId, pSupports);								nsAllocator::Free(pSupports);							}							nsAllocator::Free(pClsId);						}						}				}				node->Release();			}			base->Release();		}		if (NS_SUCCEEDED( rv))			rv = enumerator->Next();	}		m_didDiscovery = PR_TRUE;	    return NS_OK;}