NS_AutoregisterComponents();
nsCOMPtr<nsIServiceManager> servMan; NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar"); registrar->AutoRegister(nsnull);
main(int argc, char *argv[]){  nsresult ret;  NS_AutoregisterComponents();  nsIStringBundleService* service = nsnull;  ret = nsServiceManager::GetService(kStringBundleServiceCID,                                     kIStringBundleServiceIID, (nsISupports**) &service);  if (NS_FAILED(ret)) {    printf("cannot create service\n");    return 1;  }  PRUnichar *uiLang = nsnull;  PRUnichar *country = nsnull;  ret = getUILangCountry(&uiLang, &country);#if DEBUG_tao  nsAutoString uaStr(uiLang); // testing only  nsAutoString countryStr(country); // testing only  cout << "\n uaStr=" << ToNewCString(uaStr)        << ", country=" << ToNewCString(countryStr)        << "\n" << endl;#endif  nsIStringBundle* bundle = nsnull;  ret = service->CreateBundle(TEST_URL, &bundle);  if (NS_FAILED(ret)) {    printf("cannot create instance\n");    return 1;  }  nsAutoString v;  v.Assign(NS_LITERAL_STRING(""));  PRUnichar *ptrv = nsnull;  char *value = nsnull;  // 123  ret = bundle->GetStringFromID(123, &ptrv);  if (NS_FAILED(ret)) {    printf("cannot get string from ID 123, ret=%d\n", ret);    return 1;  }  v = ptrv;  value = ToNewCString(v);  cout << "123=\"" << value << "\"" << endl;  // file  nsString strfile;  strfile.Assign(NS_LITERAL_STRING("file"));  const PRUnichar *ptrFile = strfile.get();  ret = bundle->GetStringFromName(ptrFile, &ptrv);  if (NS_FAILED(ret)) {    printf("cannot get string from name\n");    return 1;  }  v = ptrv;  value = ToNewCString(v);  cout << "file=\"" << value << "\"" << endl;  return 0;}