1

Chrome拡張機能からC言語を使用して記述されたDLLでエクスポートされた関数を1つ呼び出したいと思いました。しかし、それを行う方法について十分な情報が得られていません。

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);

Chromeexteniosnsを使用してそれを行う方法について教えてください

4

1 に答える 1

1

マニフェストファイルを基準にしてFRViewPortExtn.dllを配置し、次のコードをmanifest.jsonに追加します

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

このコードを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

詳細については、https://developer.chrome.com/extensions/npapi.htmlを参照してください。

于 2012-11-22T11:38:19.277 に答える