foundReg = PR_TRUE;
nsCOMPtr<nsIProperties> directoryService; rv = nsDirectoryService::Create(nsnull, NS_GET_IID(nsIProperties), getter_AddRefs(directoryService)); if (NS_FAILED(rv)) return rv; directoryService->Get(NS_XPCOM_APPLICATION_REGISTRY_FILE, NS_GET_IID(nsIFile), getter_AddRefs(registryLocation));  if (registryLocation) { foundReg = PR_TRUE; registryLocation->GetPath(&regFile);   if (!regFile) return NS_ERROR_OUT_OF_MEMORY; }
NS_IMETHODIMP nsRegistry::OpenWellKnownRegistry( nsWellKnownRegistry regid ) {    REGERR err = REGERR_OK;    if (mCurRegID != nsIRegistry::None && mCurRegID != regid)    {        // Cant open another registry without closing explictly.        return NS_ERROR_INVALID_ARG;    }    if (mCurRegID == regid)    {        // Already opened.        return NS_OK;    }    nsresult rv;    nsCOMPtr<nsIFile> registryLocation;    PRBool foundReg = PR_FALSE;    char *regFile = nsnull;        switch ( (nsWellKnownRegistry) regid ) {      case ApplicationComponentRegistry:        {            nsCOMPtr<nsIProperties> directoryService;            rv = nsDirectoryService::Create(nsnull,                                             NS_GET_IID(nsIProperties),                                             getter_AddRefs(directoryService));            if (NS_FAILED(rv)) return rv;            directoryService->Get(NS_XPCOM_COMPONENT_REGISTRY_FILE, NS_GET_IID(nsIFile),                                           getter_AddRefs(registryLocation));            if (registryLocation)            {                foundReg = PR_TRUE;                registryLocation->GetPath(&regFile);  // dougt fix...                // dveditz needs to fix his registry so that I can pass an                // nsIFile interface and not hack                 if (!regFile)                  return NS_ERROR_OUT_OF_MEMORY;            }                    }        break;      case ApplicationRegistry:        {            foundReg = PR_TRUE;            // NULL regFile will open the right one for this case.        }        break;      default:        break;    }    if (foundReg == PR_FALSE) {        return NS_ERROR_REG_BADTYPE;    }   #ifdef DEBUG_dp    printf("nsRegistry: Opening std registry %s\n", regFile);#endif /* DEBUG_dp */    PR_Lock(mregLock);    err = NR_RegOpen((char*)regFile, &mReg );    PR_Unlock(mregLock);    if (regFile)      nsMemory::Free(regFile);    // Store the registry that was opened for optimizing future opens.    mCurRegID = regid;    // Convert the result.    return regerr2nsresult( err );}