nsCOMPtr<nsIEnumerator> enumKeys; nsIRegistry::Key sourceKey, destKey, profileRootKey;  nsresult rv = m_reg->OpenDefault();
NS_ENSURE_ARG_POINTER(oldProfile); NS_ENSURE_ARG_POINTER(newProfile);
nsresult nsProfile::CopyRegKey(const char *oldProfile, const char *newProfile){	nsCOMPtr<nsIEnumerator> enumKeys;    nsIRegistry::Key sourceKey, destKey, profileRootKey;    	nsresult rv = m_reg->OpenDefault();	// Need to add else statements to print the error stages.	if (NS_SUCCEEDED(rv))	{		rv = m_reg->GetSubtree(nsIRegistry::Common, "Profiles", &profileRootKey);		if (NS_SUCCEEDED(rv))		{			rv = m_reg->GetSubtree(profileRootKey, (char *) oldProfile, &sourceKey);			if (NS_SUCCEEDED(rv))			{				rv = m_reg->AddSubtree(profileRootKey, (char *) newProfile, &destKey);				if (NS_SUCCEEDED(rv))				{	                rv = m_reg->EnumerateValues(sourceKey, getter_AddRefs(enumKeys));					if (NS_SUCCEEDED(rv)) {						rv = enumKeys->First();                    						// Enumerate subkeys till done.						while( NS_SUCCEEDED( rv ) && (NS_OK != enumKeys->IsDone()) ) 						{							nsCOMPtr<nsISupports> base;							rv = enumKeys->CurrentItem(getter_AddRefs(base));                    							// Test result.							if (NS_SUCCEEDED(rv)) 							{								// Get specific interface.								nsIRegistryNode *value;								nsIID valueIID = NS_IREGISTRYVALUE_IID;								rv = base->QueryInterface( valueIID, (void**)&value );                        								// Test that result.								if (NS_SUCCEEDED(rv)) 								{									// Get node name.									nsXPIDLCString entryName;									nsXPIDLCString entryValue;																	rv = value->GetName(getter_Copies(entryName));																	if (NS_SUCCEEDED(rv)) 									{										rv = m_reg->GetString( sourceKey, entryName, getter_Copies(entryValue));										if (NS_SUCCEEDED(rv)) 										{											rv = m_reg->SetString(destKey, entryName, entryValue);										}									}								}							}							rv = enumKeys->Next();						}					}				}			}		}		m_reg->Close();	}	return rv;}