I am sorry, but I think I did not explain myself. I can use my component from javascript in a XUL application. But I want to create an instance of a class implemented in this component from javascript in a HTML page, like crypto.sygnText function of netscape 4. I am using xpcomglue.lib library. In LINUX, when I register the component and I try to get the component manager:

  nsCOMPtr<nsICategoryManager> catman =
      do_GetService(NS_CATEGORYMANAGER_CONTRACTID, &rv);

and I get the component and the registration works.

But when I do this in WINDOWS, the same line code returns "nsnull", and "NS_ERR_FAILURE" in rv. Making some additional tests, I try to get service manager before getting category manager and I get "NS_ERR_NOT_INITIALIZED". It seems that, in WINDOWS, when the component registers itself the component manager is not ready. And one more thing, if I link the DLL with the xpcom.dll intead of xpcomglue.lib in the same line code I get the component manager successfuly. But I would like not to link with xpcom.dll, because this way the same component does not works in other versions of mozilla (in LINUX the same .so component works in other versions)

May be I want something that it is not posible right now!?.

Thank you very much!


PD. If you want more details, here is a more extended explanation:


I have defined the factory:

NS_GENERIC_FACTORY_CONSTRUCTOR(nsCLABSignString)

but (as in XMLExtras component) I define the class I want to export to "HTML javascript" and I need to define ("CLABSignString" is the class name):

NS_DECL_DOM_CLASSINFO(CLABSignString)

and then define CLABExtras like this:

NS_DOMCI_EXTENSION(CLABExtras)
static NS_DEFINE_CID(kCLABSignStringCID, NS_CLABSIGNSTRING_CID);
NS_DOMCI_EXTENSION_ENTRY_BEGIN(CLABSignString)
NS_DOMCI_EXTENSION_ENTRY_INTERFACE(nsICLABSignString)
NS_DOMCI_EXTENSION_ENTRY_END_NO_PRIMARY_IF(CLABSignString, PR_TRUE, &kCLABSignStringCID)
NS_DOMCI_EXTENSION_END


....

I define too:
  NS_INTERFACE_MAP_BEGIN(nsCLABExtrasNameset)
    NS_INTERFACE_MAP_ENTRY(nsISupports)
  NS_INTERFACE_MAP_END

  NS_IMPL_ADDREF(nsCLABExtrasNameset)
  NS_IMPL_RELEASE(nsCLABExtrasNameset)

  NS_IMPL_ADDREF(nsCLABExtras)
  NS_IMPL_RELEASE(nsCLABExtras)

  NS_INTERFACE_MAP_BEGIN(nsCLABExtras)
    NS_INTERFACE_MAP_ENTRY(nsISupports)
  NS_INTERFACE_MAP_END

NS_GENERIC_FACTORY_CONSTRUCTOR(nsCLABExtras)

static nsModuleComponentInfo components[] =
{{"CLABExtras component", NS_CLAB_EXTRAS_CID, NS_CLAB_EXTRAS_CONTRACTID,nsCLABExtrasConstructor,RegisterCLABExtras
},
{
NS_CLABSIGNSTRING_CLASSNAME, NS_CLABSIGNSTRING_CID, NS_CLABSIGNSTRING_CONTRACTID,nsCLABSignStringConstructor
},
{ "CLAB Extras DOMCI Extender",
CLABEXTRAS_DOMCI_EXTENSION_CID, CLABEXTRAS_DOMCI_EXTENSION_CONTRACTID,
NS_DOMCI_EXTENSION_CONSTRUCTOR(CLABExtras)
}};


  void PR_CALLBACK
  CLABExtrasModuleDestructor(nsIModule* self){
    NS_IF_RELEASE(NS_CLASSINFO_NAME(CLABSignString));
  }

  NS_IMPL_NSGETMODULE_WITH_DTOR("SECCLAB", components,
                              CLABExtrasModuleDestructor)

David Bradley wrote:
lfern wrote:

David Bradley wrote:

*** Registering "SECCLAB" components (all right -- a generic module!)
nsGenericModule "SECCLAB": Register hook for CLABExtras component component retu
rned error => 80004005


Ok, I misunderstood. Your control is getting the error when its registered. So it is being found. Ideally you should be using macros to build the registering code. From what I can tell if you're using the macros properly the only thing that could error is QI of nsGenericModule, which would be highly unlikely. Below is an example of such code. Did you create your own factory constructor?

NS_GENERIC_FACTORY_CONSTRUCTOR(cppImplementationClass)

static const nsModuleComponentInfo components[] = {
{ "a descriptive name for the component",
{ 0x12345678, 0x1234, 0x1234, { 0x12, 0x34, 0x56, 0x78, 0x90, 0x12, 0x34, 0x56 } },
"your.prog.id",
cppImplementationClassConstructor }
};


NS_IMPL_NSGETMODULE(your_module, components)





Reply via email to