RegisterTestFactories();
nsCOMPtr<nsIServiceManager> servMan; rv = NS_InitXPCOM2(getter_AddRefs(servMan), nsnull, nsnull); if (NS_FAILED(rv)) return -1; nsCOMPtr<nsIComponentRegistrar> registrar = do_QueryInterface(servMan); NS_ASSERTION(registrar, "Null nsIComponentRegistrar");  registrar->RegisterFactory(kTestFactoryCID, nsnull, nsnull, new TestFactory());
int main(int argc, char **argv) {  nsresult rv;  rv = nsComponentManager::AutoRegister(nsIComponentManagerObsolete::NS_Startup,                                        NULL /* default */);  if (NS_FAILED(rv)) return rv;  RegisterTestFactories();  ITestClass *t = NULL;  nsComponentManager::CreateInstance(kTestFactoryCID,                               NULL,                               NS_GET_IID(ITestClass),                               (void **) &t);  if (t != NULL) {    t->Test();    t->Release();  } else {    cout << "CreateInstance failed\n";  }  t = NULL;  nsComponentManager::CreateInstance(kTestLoadedFactoryCID,                               NULL,                               NS_GET_IID(ITestClass),                               (void **) &t);  if (t != NULL) {    t->Test();    t->Release();  } else {    cout << "Dynamic CreateInstance failed\n";  }  nsComponentManager::FreeLibraries();  return 0;}