English 中文(简体)
构成部分3.6:内容如何?
原标题:Components.interfaces.nsIProcess2 in Firefox 3.6 -- where did it go?

我正在进行一个应用的Beta测试,其中包括Firefox扩展作为一个组件。最初是在FF3.5.5版本发布时部署的,并且经历了3.5.6和3.5.7版本。但是在FF3.6上,我的错误控制台显示以下内容:

Warning: reference to undefined property Components.interfaces.nsIProcess2
Source file: chrome://overthewall/content/otwhelper.js
Line: 55

Error: Component returned failure code: 0x80570018 (NS_ERROR_XPC_BAD_IID) 
         [nsIJSCID.createInstance]
Source file: chrome://overthewall/content/otwhelper.js
Line: 55

抛出错误的函数是:

48 function otwRunHelper(cmd, aCallback) {
49  var file =
50      Components.classes["@mozilla.org/file/local;1"].
51      createInstance(Components.interfaces.nsILocalFile);
52  file.initWithPath(otwRegInstallDir+ otwhelper.exe );
53
54  otwProcess = Components.classes["@mozilla.org/process/util;1"]
55                  .createInstance(Components.interfaces.nsIProcess2);
56
57  otwProcess.init(file);
58  var params = new Array();
59  params = cmd.split(   );
60  
61  otwNextCallback = aCallback;
62  otwObserver = new otwHelperProcess();
63  otwProcess.runAsync(params, params.length, otwObserver, false);
64 }

如你所知,所有这项职能都是由外部EXE求助员(由登记处钥匙定位)管理,具有某些指挥线参数,并设立观察员,以不时地等待答复和处理Exit代码。

犯罪线意味着Components.interfaces.nsIProcess2在FF3.6中不再界定。 什么时候? 我无法在“彩虹”文件中找到任何东西,表明它在最近的释放中发生了变化。

最佳回答

nsIProcess2上的方法已移至nsIProcess。为了使您的代码在两个版本中都可以工作,请更改此行:

otwProcess = Components.classes["@mozilla.org/process/util;1"]
                .createInstance(Components.interfaces.nsIProcess2);

将此翻译成中文:到这里:

otwProcess = Components.classes["@mozilla.org/process/util;1"]
                .createInstance(Components.interfaces.nsIProcess2 || Components.interfaces.nsIProcess);

你们仍会得到警告,但错误将会消失,你的法典将在两种版本中仅作罚款。 您还可以将接口单贴在一个变量中,并使用变量:

let iid = ("nsIProcess2" in Components.interfaces) ?
  Components.interfaces.nsIProcess2 :
  Components.interfaces.nsIProcess;
otwProcess = Components.classes["@mozilla.org/process/util;1"]
                .createInstance(iid);
问题回答

暂无回答




相关问题
How to implement a timer in a XPCOM component?

I m creating a GStreamer application based on XULRunner. To achieve this created an XPCOM component that makes some of the GStreamer functionality available in a XUL application. However, GStreamer ...

XPCOM Shockwave Flash C++

I recently started "playing" with xpcom, and I would like to know if there is a way do interact with a Shockwave flash element. In IE I can use the IShockwaveFlash interface, but for the Firefox I ...

virtualbox and python API

0 vote down I have installed virtualbox . but i cant import the module xpcom. but the synaptic package shows that it is installed. what could be wrong? -ASK

Cant find a way to open AppData/LocalLow directory

I am able to get path to User AppData/Local folder as follows. appdatafile = Components.classes["@mozilla.org/file/directory_service;1"]. getService(Components.interfaces.nsIProperties). get("...

Detecting Firefox extension version

I have a Firefox Extension that I would like to populate the About box with the version within install.rdf. I know that FUEL s extIExtension allows one to see the version for an extension but I did ...

Accessing tabs on Firefox with a C++ XPCOM extension

What XPCOM interfaces should I use to detect opening, closing and switching of tabs and also get their associated URL from a firefox extension? I have seen instances of code that manage tabs in JS, ...

XPCOM Security issues

I m developing a Firefox plugin using XPCOM, I ve not yet read all the docs, but as far as I can see, A plugin is simply a DLL that provides services via a XPCOM interface and interacts with the ...

How do I link to a DLL from javascript in XULRunner?

I have a dll (that I didn t write) and I would like to use it in an XULRunner application. I know nearly nothing about this, so bear with me. Apparently I can use XPCOM to load the dll and then call ...

热门标签