nsAutoString path(NS_LITERAL_STRING("software/mozilla/XPCOM/classID/") + NS_ConvertUCS2toASCII(aCID));
nsAutoString path(NS_LITERAL_STRING("software/mozilla/XPCOM/classID/") + NS_ConvertASCIItoUCS2(aCID));
LoadXPCOMPlugin(nsIComponentManager* aComponentManager,                nsIRegistry* aRegistry,                const char* aCID,                nsRegistryKey aPluginKey,                nsPluginTag** aResult){  nsresult rv;  // The name, description, MIME types, MIME descriptions, and  // supported file extensions will all hang off of the plugin's key  // in the registry. Pull these out now.  nsXPIDLCString name;  aRegistry->GetStringUTF8(aPluginKey, "name", getter_Copies(name));  nsXPIDLCString description;  aRegistry->GetStringUTF8(aPluginKey, "description", getter_Copies(description));  nsXPIDLCString filename;  // To figure out the filename of the plugin, we'll need to get the  // plugin's CID, and then navigate through the XPCOM registry to  // pull out the DLL name to which the CID is registered.  nsAutoString path(NS_LITERAL_STRING("software/mozilla/XPCOM/classID/") + NS_ConvertUCS2toASCII(aCID));  nsRegistryKey cidKey;  rv = aRegistry->GetKey(nsIRegistry::Common, path.GetUnicode(), &cidKey);  if (NS_SUCCEEDED(rv)) {    PRUint8* library;    PRUint32 count;    // XXX Good grief, what does "GetBytesUTF8()" mean? They're bytes!    rv = aRegistry->GetBytesUTF8(cidKey, "InprocServer", &count, &library);    if (NS_SUCCEEDED(rv)) {      nsCOMPtr<nsIFile> file;      rv = aComponentManager->SpecForRegistryLocation(NS_REINTERPRET_CAST(const char*, library),                                                      getter_AddRefs(file));      if (NS_SUCCEEDED(rv)) {        file->GetPath(getter_Copies(filename));      }      nsCRT::free(NS_REINTERPRET_CAST(char*, library));    }  }  nsCOMPtr<nsIEnumerator> enumerator;  rv = aRegistry->EnumerateAllSubtrees(aPluginKey, getter_AddRefs(enumerator));  if (NS_FAILED(rv)) return rv;  nsCOMPtr<nsISimpleEnumerator> subtrees;  rv = NS_NewAdapterEnumerator(getter_AddRefs(subtrees), enumerator);  if (NS_FAILED(rv)) return rv;  char** mimetypes = nsnull;  char** mimedescriptions = nsnull;  char** extensions = nsnull;  PRInt32 count = 0;  PRInt32 capacity = 0;  for (;;) {    PRBool hasmore;    subtrees->HasMoreElements(&hasmore);    if (! hasmore)      break;    nsCOMPtr<nsISupports> isupports;    subtrees->GetNext(getter_AddRefs(isupports));    nsCOMPtr<nsIRegistryNode> node = do_QueryInterface(isupports);    NS_ASSERTION(node != nsnull, "not an nsIRegistryNode");    if (! node)      continue;    nsRegistryKey key;    node->GetKey(&key);    if (count >= capacity) {      capacity += capacity ? capacity : 4;      char** newmimetypes        = new char*[capacity];      char** newmimedescriptions = new char*[capacity];      char** newextensions       = new char*[capacity];      if (!newmimetypes || !newmimedescriptions || !newextensions) {        rv = NS_ERROR_OUT_OF_MEMORY;        delete[] newmimetypes;        delete[] newmimedescriptions;        delete[] newextensions;        break;      }      for (PRInt32 i = 0; i < count; ++i) {        newmimetypes[i]        = mimetypes[i];        newmimedescriptions[i] = mimedescriptions[i];        newextensions[i]       = extensions[i];      }      delete[] mimetypes;      delete[] mimedescriptions;      delete[] extensions;      mimetypes        = newmimetypes;      mimedescriptions = newmimedescriptions;      extensions       = newextensions;    }    aRegistry->GetStringUTF8(key, "mimetype",    &mimetypes[count]);    aRegistry->GetStringUTF8(key, "description", &mimedescriptions[count]);    aRegistry->GetStringUTF8(key, "extension",   &extensions[count]);    ++count;  }  if (NS_SUCCEEDED(rv)) {    // All done! Create the new nsPluginTag info and send it back.    nsPluginTag* tag      = new nsPluginTag(name.get(),                        description.get(),                        filename.get(),                        (const char* const*)mimetypes,                        (const char* const*)mimedescriptions,                        (const char* const*)extensions,                        count);    if (! tag)      rv = NS_ERROR_OUT_OF_MEMORY;    *aResult = tag;  }  for (PRInt32 i = 0; i < count; ++i) {    CRTFREEIF(mimetypes[i]);    CRTFREEIF(mimedescriptions[i]);    CRTFREEIF(extensions[i]);  }  delete[] mimetypes;  delete[] mimedescriptions;  delete[] extensions;  return rv;}