int nFailed = 0;  nsCOMPtr<nsICategoryManager> categoryManager = do_GetService(NS_CATEGORYMANAGER_PROGID, &rv); if (NS_FAILED(rv)) return rv;
int nFailed = 0; nsCOMPtr<nsICategoryManager> categoryManager = do_GetService("mozilla.categorymanager.1", &rv); if (!categoryManager) return rv;
CategoryCreateService( const char *category ){    nsresult rv = NS_OK;    int nFailed = 0;    nsCOMPtr<nsICategoryManager> categoryManager = do_GetService(NS_CATEGORYMANAGER_PROGID, &rv);    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsISimpleEnumerator> enumerator;    rv = categoryManager->EnumerateCategory(category, getter_AddRefs(enumerator));    if (NS_FAILED(rv)) return rv;    nsCOMPtr<nsISupports> entry;    while (NS_SUCCEEDED(enumerator->GetNext(getter_AddRefs(entry))))    {        // From here on just skip any error we get.        nsCOMPtr<nsISupportsString> catEntry = do_QueryInterface(entry, &rv);        if (NS_FAILED(rv))        {            nFailed++;            continue;        }        nsXPIDLCString cidString;        rv = catEntry->GetData(getter_Copies(cidString));        if (NS_FAILED(rv))        {            nFailed++;            continue;        }        nsCID cid;        rv = cid.Parse(cidString);        if (NS_SUCCEEDED(rv))        {#ifdef DEBUG_dp            printf("CategoryCreateInstance: Instantiating cid: %s in category %s.\n",                   (const char *)cidString, category);#endif /* DEBUG_dp */            // Create a service from the cid            nsCOMPtr<nsISupports> instance = do_GetService(cid, &rv);        }        else        {#ifdef DEBUG_dp            printf("HTTP Handler: Instantiating progid %s in http startup category.\n", (const char *)cidString);#endif /* DEBUG_dp */            // This might be a progid. Try that too.            nsCOMPtr<nsISupports> instance = do_GetService(cidString, &rv);        }        if (NS_FAILED(rv))        {            nFailed++;        }    }    return (nFailed ? NS_ERROR_FAILURE : NS_OK);}