Hello,

To register my xpcomponent which is located in: "c:\myfolder\Mycomponent.dll" using nsIComponentRegistrar
I have some codes like this:

int main(void) {
        nsresult        rv;
        nsCOMPtr<nsILocalFile> pLocalFile;
rv = NS_NewNativeLocalFile(nsEmbedCString("c:\myfolder\mycomponent.dll"), PR_FALSE, getter_AddRefs(pLocalFile));
        nsCOMPtr<nsIFile> pFile   = pLocalFile;
        nsCOMPtr<nsIComponentRegistrar> pComponentReg     = nsnull;
        rv      = NS_GetComponentRegistrar(getter_AddRefs(pComponentReg));
        if (!NS_FAILED(rv)) {
                if (pComponentReg != nsnull) {
                        rv      = pComponentReg->AutoRegister(pFile);
                }
        }
}


Everything seems to be ok. All statuses were NS_OK. Moreover, I can see the static registration function of my componet got called successfully:


static NS_METHOD MycomponentRegistration(
        nsIComponentManager *aCompMgr,
        nsIFile *aPath,
        const char *registryLocation,
        const char *componentType,
        const nsModuleComponentInfo *info
        )
{
        nsresult        rv;
        
        nsCOMPtr<nsIServiceManager> servman;
        rv = NS_GetServiceManager(getter_AddRefs(servman));
        if (NS_FAILED(rv))
                return rv;

        nsCOMPtr<nsICategoryManager> catman;
rv = 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",      
                GNPMOZILLA_CLASSNAME,
                GNPMOZILLA_CONTRACTID,
                PR_TRUE,
                PR_TRUE,
                &previous
                );
        if (previous)
                nsMemory::Free(previous);
        return rv;
}



But, still the contents of "compreg.dat" and the "xpti.dat" did not change (after installing, these files are supposed to contain infomation on my component as well as its location). The component was not registered.

Do you, Christian  or anyone else has a clue where I went wrong?

Best regards
Vonuyx









Christian Biesinger wrote:

vonuyx wrote:

Hello,
I am just wondering whether it is possible to install an xpcom component from within C++ code in the way like regxpxom.exe does?


Try nsIComponentRegistrar

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

Reply via email to