Martin Koppmann wrote:
Hi,

I have a working XPCOM Sample.
I am searching for way to register this component after copying it into the
components directory, since non debug-mozilla do not do this automatically.
I do not want the users to register the component manually because firefox
browser does not seem to have regxpcom.exe.

Therefore the install.js in the xpi file should do this.

According the source of regxpcom a nsiLocalFile object is passed to the
autoregister function.
The C++ source uses NS_NewNativeLocalFile.

I do not know how to initialize the file object in JavaScript.
Can you help me? Below is my code.

function autoRegister()
{
  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);
}


Thank you! Martin



Assuming you have just copied your javascript xpcom component into the xpcom components directory, you would need to run some other code to register this component.

There are a few ways to do this:

A) touch a file .autoreg next to the executable.
B) run regxpcom with the right commands.
C) install the component via xpinstall.
D) run some priveleged js (as your code above attempts to do)

For your code above, you can simply pass null to autoRegister. Also, you never have to register the xpt (type library) -- just the javascript components.

Regards,
Doug Turner
_______________________________________________
Mozilla-xpcom mailing list
[EMAIL PROTECTED]
http://mail.mozilla.org/listinfo/mozilla-xpcom

Reply via email to