Hi all i have just written a xpcom c++ component. i hvae used regxpcom
for registration but after closing firefox iam getting an invalid page
fault error. So i have started registering the components using
registersel and unregisterself,but still my component is not registered
properly. And i do no how to iniatiate that registration process . can
anyone help me in this .
MyComponent::MyComponent()
{
NS_INIT_ISUPPORTS();
nsCOMPtr<nsIComponentRegistrar> registrar =
do_QueryInterface(servMan);
nsresult rv = NS_GetComponentRegistrar(getter_AddRefs(registrar));
registrar->AutoRegister(nsnull);
}
MyComponent::~MyComponent()
{
registrar->AutoUnregister(nsnull);
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)
{
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)
{
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;
}
Whats wrong in this code ?
_______________________________________________
Mozilla-xpcom mailing list
[email protected]
http://mail.mozilla.org/listinfo/mozilla-xpcom