Now i got a problem in registration.Message box Registration is
displayin during first time firefox loads but Unregistration is not
calling properly. And i do no when to inittiate my xpcom and shutdown
xpcom. Here is my code
MyComponent::MyComponent()
{
rv = NS_InitXPCOM2(nsnull, nsnull, nsnull);
}
MyComponent::~MyComponent()
{
NS_ShutdownXPCOM(nsnull );
}
NS_IMETHODIMP MyComponent::Observe(nsISupports *aSubject, const char
*aTopic, const PRUnichar *aData)
{
return NS_OK;
}
static NS_METHOD MyComponentRegistration(nsIComponentManager
*aCompMgr,nsIFile *aPath,const char *registryLocation,const char
*componentType,const nsModuleComponentInfo *info)
{
MessageBox(NULL,"Registration","Title",NULL);
nsresult rv;
nsCOMPtr<nsIServiceManager> servman;
servman = do_QueryInterface((nsISupports*)aCompMgr, &rv);
if (NS_FAILED(rv)) return rv;
nsCOMPtr<nsICategoryManager> catman;
servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,NS_GET_IID(nsICategoryManager),getter_AddRefs(catman));
if (NS_FAILED(rv)) return rv;
char* previous = nsnull;
rv =
catman->AddCategoryEntry("xpcom-startup",MY_COMPONENT_CLASSNAME,MY_COMPONENT_CONTRACTID,PR_TRUE,PR_TRUE,&previous);
if (previous)
nsMemory::Free(previous);
return rv;
}
static NS_METHOD MyComponentUnregistration(nsIComponentManager
*aCompMgr,nsIFile *aPath,const char *registryLocation,const
nsModuleComponentInfo *info)
{
MessageBox(NULL,"UnRegistration","Title",NULL);
nsresult rv;
nsCOMPtr<nsIServiceManager> servman =
do_QueryInterface((nsISupports*)aCompMgr, &rv);
if (NS_FAILED(rv))return rv;
nsCOMPtr<nsICategoryManager> catman;
servman->GetServiceByContractID(NS_CATEGORYMANAGER_CONTRACTID,NS_GET_IID(nsICategoryManager),getter_AddRefs(catman));
if (NS_FAILED(rv))return rv;
rv =
catman->DeleteCategoryEntry("xpcom-startup",MY_COMPONENT_CLASSNAME,PR_TRUE);
return rv;
}
.
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom