nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));
nsCOMPtr<nsIPref> pPref(do_GetService(NS_PREF_CONTRACTID, &rv));
static char *DIR_GetStringPref(const char *prefRoot, const char *prefLeaf, char *scratch, const char *defaultValue){    nsresult rv = NS_OK;    nsCOMPtr<nsIPref> pPref(do_GetService(kPrefCID, &rv));     if (NS_FAILED(rv) || !pPref) 		return nsnull;	char *value = nsnull;	PL_strcpy(scratch, prefRoot);	PL_strcat(scratch, ".");	PL_strcat(scratch, prefLeaf); 	if (PREF_NOERROR == pPref->CopyCharPref(scratch, &value))	{		/* unfortunately, there may be some prefs out there which look like this */		if (!PL_strcmp(value, "(null)")) 		{			PR_FREEIF(value); /* free old value because we are going to give it a new value.... */            value = defaultValue ? nsCRT::strdup(defaultValue) : nsnull;		}		if (PL_strlen(value) == 0)		{			PR_FREEIF(value);			pPref->CopyDefaultCharPref(scratch, &value);		}	}	else	{		PR_FREEIF(value); /* the pref may have generated an error but we still might have something in value...... */        value = defaultValue ? nsCRT::strdup(defaultValue) : nsnull;	}	return value;}