我想从我的 chrome 扩展调用使用 C 语言编写的 Dll 中的一个导出函数。但没有获得足够的信息来说明如何做到这一点。
在 Firefox 中,我在扩展 js 文件中使用下面提到的代码来执行此操作,但在 chrome 中不起作用。
var InstallPath="C:\\FRViewPortExtn.dll";
Components.utils.import("resource://gre/modules/ctypes.jsm");
var lib = ctypes.open(InstallPath);
/* Declare the signature of the function we are going to call */
passBrowserResizeData = lib.declare("SetViewPort",
ctypes.winapi_abi,
ctypes.void_t,
ctypes.int32_t,
ctypes.float32_t,
ctypes.int32_t,
ctypes.int32_t);
并使用调用
passBrowserResizeData(6,7,8,9);
请帮助我了解如何使用 chrome exteniosns 来完成此操作
最佳答案
将 FRViewPortExtn.dll 相对于 list 文件放置,并将以下代码添加到 manifest.json
"plugins": [
{ "path": "FRViewPortExtn.dll", "public": true },
],
将这段代码放入你的JS中(内容js\背景js\扩展js)
var plugin = document.getElementById("pluginId");
var result = plugin.passBrowserResizeData(6,7,8,9); // call a method in your plugin
欲了解更多信息,请参阅https://developer.chrome.com/extensions/npapi.html
关于javascript - 如何从 chrome 扩展调用 DLL 中的导出函数(使用 C 编写),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13511805/