I am trying to acess the cookiemanager component through an independent application . I have written an application
which initializes xpcom and tries to create the instance of cookiemanager . But it fails with error 0x80040154 ( factory is not registerd). To register the factory for cookiemanager i need to have xpcom dll which has implemented the cookiemanager interface.
After doing some analysis i have found that all xpcom modules which firefox uses are built into the firefox itself. There is no seperate dll for these xpcom components. So i was wondering is there any other way through which i can utilize these xpcom components independenly without running inside the mozilla environment ( extension / plugins...etc )
I have attached the sample code for your reference.
Let me know if you find any thing wrong in the above text .
Any links / ideas will be greatly appreciated..
Thank you
--
With Regards
Nagareshwar
#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;
}
// Register factory here...
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;
}
