How to call exported function in a DLL(written using C), from chrome extensions

三世轮回 提交于 2019-12-14 04:01:09

问题


I wanted to call one exported function in a Dll written using C Language from my chrome extensions. But not getting sufficient info on how to do that.

In Firefox I am using below mention code in my extensions js file to do so, but same is not working in 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);

and calling using

passBrowserResizeData(6,7,8,9);

Please help me on how it can be done using chrome exteniosns


回答1:


Place FRViewPortExtn.dll relative to manifest file and add the following code to manifest.json

"plugins": [
    { "path": "FRViewPortExtn.dll", "public": true },
  ],

Put this piece of code in your JS(content js\background js\extension js)

var plugin = document.getElementById("pluginId");
var result = plugin.passBrowserResizeData(6,7,8,9);  // call a method in your plugin

For more information refer https://developer.chrome.com/extensions/npapi.html



来源:https://stackoverflow.com/questions/13511805/how-to-call-exported-function-in-a-dllwritten-using-c-from-chrome-extensions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!