2

我想从 google chrome 或 Firefox 调用 Windows(仅限 7/Vista/XP)应用程序。我正在考虑制作一个插件来做到这一点。我可以查看这里提到的教程如何制作 firefox 或 google Chrome 插件?. 但是,在此之前,我想知道是否可以从这些浏览器调用 Windows 应用程序。这样做是否可取?

4

1 回答 1

5

在 Chrome 上(Firefox 也支持 npapi)

你有 NPAPI (c extension) 可以直接调用 os

https://developer.chrome.com/extensions/npapi.html

ShellExecuteEx来自 npapi 的电话

在火狐上

你也有这个调用 os 命令

https://developer.mozilla.org/en-US/docs/XPCOM_Interface_Reference/nsIProcess

来自上述网址的示例

// create an nsILocalFile for the executable
var file = Components.classes["@mozilla.org/file/local;1"]
                     .createInstance(Components.interfaces.nsILocalFile);
file.initWithPath("c:\\myapp.exe");

// create an nsIProcess
var process = Components.classes["@mozilla.org/process/util;1"]
                        .createInstance(Components.interfaces.nsIProcess);
process.init(file);

// Run the process.
// If first param is true, calling thread will be blocked until
// called process terminates.
// Second and third params are used to pass command-line arguments
// to the process.
var args = ["argument1", "argument2"];
process.run(false, args, args.length);
于 2013-01-27T08:24:08.223 回答