Firefox addon 如何从Firefox插件打开外部应用程序?(例如:默认文本编辑器)

Firefox addon 如何从Firefox插件打开外部应用程序?(例如:默认文本编辑器),firefox-addon,editor,add-on,Firefox Addon,Editor,Add On,我需要我的插件将能够编辑与外部工具的一些文件。有什么想法吗 此代码段在提供路径时显示或启动文件: var localFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile); localFile.initWithPath("C:\\some-directory\\some-file.png"); if(localFile.exists()){ // localFile.reveal(); /

我需要我的插件将能够编辑与外部工具的一些文件。有什么想法吗

此代码段在提供路径时显示或启动文件:

var localFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
localFile.initWithPath("C:\\some-directory\\some-file.png");

if(localFile.exists()){
    // localFile.reveal();       // open the containing folder of the file
    // localFile.launch();       // launch the file
}
但是,您可能需要使用来运行带有参数的可执行文件(例如您试图用可执行文件打开的文件路径)

文件:

var exeFile = Cc["@mozilla.org/file/local;1"].createInstance(Ci.nsILocalFile);
exeFile.initWithPath("C:\\Program Files\\...\\app.exe");
var parameter="C:\\some-directory\\some-file.txt";
if(exeFile.exists()){
    var process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);  
    process.init(exeFile);
    process.run(false,[parameter],1);  // launch the executable with another file as parameter.
}