I had the same problem a few days ago.
Search for "account manager" in the past messages.

(try to set the second argument of InitXPCOM)

>  I have written a simple c/c++ program on windows to understand 
> how xpcom
> works. My objective is to write independent application without using
> mozilla to connect to xpcom module ( ex : cookiemanager )
> 
> Below is the very basic code which initializes xpcom and tries to 
> createinstance of  cookiemanager.  I have copied the binary into 
> the C:\Program
> Files\Mozilla Firefox folder and then executed.  Init xpcom works 
> properly ,
> but when it tries to create instance of cookie manager
> it fails with error   0x80040154 ( NS_ERROR_FACTORY_NOT_REGISTERED ).
> 
> Then I called autoregister() method before trying to create  
> instance of
> cookie manager...but that did not help...!
> 
> I am new bee to xpcom world and trying to resolve this problem 
> since last 2
> weeks without any success...
> 
> Any links in this direction will be of great help......
> 
> Thank you
> 
> 
> 
************************************************************************
***************************
> 
> #include <stdio.h>
> 
> #include <nsxpcom.h>
> #include <nsIServiceManager.h>
> #include <nsIComponentManager.h>
> #include <nsIComponentRegistrar.h>
> 
> #include "nsICookieManager.h"
> 
> #pragma comment(lib,"xpcom.lib")
> 
> 
> int main()
> {
>   nsresult rv;
> 
>   rv = NS_InitXPCOM2(NULL, nsnull, nsnull);
> 
>   if ( NS_FAILED(rv) )
>   {
>      printf("\n Init xpcom failed..");
>      return -1;
>   }
> 
>    printf("\n\n Creating the new instance of cookiemanager 
> component");
>    nsIComponentManager *compManager;
>    rv = NS_GetComponentManager(&compManager);
> 
>    nsICookieManager *cookieManager = NULL;
>    rv = compManager->CreateInstanceByContractID("@
> mozilla.org/cookiemanager;1",
>                                                 nsnull,
> 
> NS_GET_IID(nsICookieManager),
>                                                 
> (void**)&cookieManager                                             
>    );
> 
> 
>    if ( NS_FAILED(rv) || cookieManager == nsnull)
>    {
>        printf("\n CreateInstanceByContractID failed : 0x%x ", rv);
>        return -1;
>    }
> 
>    printf("\n Successfully created the instance....");
> 
> 
>    // Shutdown XPCOM
>    NS_ShutdownXPCOM(nsnull);
> 
>   return 0;
> }
> 
> 
> 
************************************************************************
*
> 
> 
> --
> With Regards
> Nagareshwar
> 

_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to