Martin,
This worked for me:
//make local file
var localFile =
Components.classes["@mozilla.org/file/local;1"].getService(Components.interf
aces.nsILocalFile);
//The following (registering only one component) doesn't seem to work
//localFile.initWithPath("c:\\Progra~1\\mozilla.org\\Mozilla\\components\\my
Component.dll");
//Instead, register everything
localFile.initWithPath("c:\\Progra~1\\mozilla.org\\Mozilla\\components\\");
var compman = Components.manager;
compman.QueryInterface(Components.interfaces.nsIComponentRegistrar);
var rtn = compman.autoRegister(localFile);
Note that the argument to "initWithPath" is the directory where the
components live, not a file name in that directory.
Susan
"Martin Koppmann" <[EMAIL PROTECTED]> wrote in message
news:[EMAIL PROTECTED]
> Thank you Doug!
>
> > A) touch a file .autoreg next to the executable.
> Can you give me an example?
>
> > B) run regxpcom with the right commands.
> The Firefox distribution doesn't include this tool in the bin directory.
>
> > C) install the component via xpinstall.
> Yes, xpinstall copies the native dll + xpt file into the components
> directory.
> But nothing gets registered after performInstall(). Compreg.dat and
xpti.dat
> are not updated!
>
> > D) run some priveleged js (as your code above attempts to do)
>
> Yes I will try this way. I now learned how to pass a valid nsIFile object
> (the xpt file) to autoregister.
> But it gives me NS_ERROR_FACTORY_NOT_REGISTERED. If I pass
> autoRegister(null) nothing happens. I expected that all components will be
> reregistered according the documentation.
>
> How can I register my component by code?
>
> Martin
>
>
>
netscape.security.PrivilegeManager.enablePrivilege("UniversalXPConnect");
> var compman=Components.manager;
> compman.QueryInterface(Components.interfaces.nsIComponentRegistrar);
> var file =
>
Components.classes['@mozilla.org/file/local;1'].createInstance(Components.in
> terfaces.nsILocalFile);
> file.initWithPath("C:\\Programme\\Mozilla
> Firefox\\components\\nsISample.xpt");
> compman.autoRegister(file);
>
>
>
>
>
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom