简体   繁体   中英

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

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

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM