1

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

Ashish Mittal
  • 643
  • 3
  • 12
  • 32

1 Answers1

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

Sudarshan
  • 18,140
  • 7
  • 53
  • 61
  • Ok Thanks for the information , I will try this but one quick question is, my FRViewPortExtn.dll is not a NPAPI dll , its just a plain C Dll. So can we achieve this without writting NPAPI plugin? – Ashish Mittal Nov 22 '12 at 13:28
  • I wrote one NPAPI plugin.In my manifest file I have declared backgroud.html file which loads this npapi plugin and give some id to that plugin. Till this point it is fine,my plugin is getting loaded successfully. But the problem is I can capture browser resize events only and only in js which is specified in content_script section.There if I am trying to get the instance of my loaded npapi plugin using document.getelementbyid("plugin ID which is loaded by backgroud.html") , it is failing here.please suggest how can i get my loaded plugin instance from content script js files. – Ashish Mittal Nov 23 '12 at 14:49