是否可以使用 main(int argc, char** argv) 参数启动本地主机?用background.js写比较合理,但是没有chrome.runtime.connectNative(string application, string[] arguments)这样的api。只有 chrome.runtime.connectNative(string application)。
最佳答案
据我所知,您希望做的最好的事情就是创建一个 .bat 文件(或等效文件)并从那里传递参数。如果您有要从扩展传递的动态数据(您不能将其硬编码到启动器脚本文件中),那么您将需要开发一个协议(protocol)来启动启动序列以确保您的参数已被处理,例如
var startupDone = false,
port = chrome.runtime.connectNative( 'my.native.app' );
port.onMessage.addListener( function( msg ) {
if ( msg.type === 'startupResponse' && msg.done ) startupDone = true;
else {
// process normal messages
}
} );
port.postMessage( { type: 'startupRequest', params: [] } );
...
if ( startupDone ) {
port.postMessage( /* non-startup message */ );
}
关于c++ - chrome 原生消息 : can a native host executable start with arguments?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33473945/