我想通过谷歌浏览器或Firefox调用Windows(仅限7 / Vista / XP)应用程序。我正在考虑制作一个插件来做到这一点。我可以查看这里提到的教程How to make firefox or google Chrome Add-on?。但是,在此之前我想知道是否可以从这些浏览器调用Windows应用程序。做这样的事情是否明智?
答案 0 :(得分:4)
在Chrome上(Firefox也支持npapi)
你有NPAPI(c扩展名)直接调用os
https://developer.chrome.com/extensions/npapi.html
从npapi
致电ShellExecuteEx
在Firefox上
你也可以调用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);