如何从chrome扩展中调用DLL中的导出函数(使用C编写) [英] How to call exported function in a DLL(written using C), from chrome extensions

查看:464
本文介绍了如何从chrome扩展中调用DLL中的导出函数(使用C编写)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在我的Chrome扩展中使用C语言编写的一个Dll中调用一个导出的函数。但是没有得到足够的信息。

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.

在Firefox中,我在扩展js文件中使用了下面提到的代码来完成这项工作,但是它在Chrome中不起作用。

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

并使用

passBrowserResizeData(6,7,8,9);

请帮助我如何使用chrome exteniosns来完成

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

推荐答案

将FRViewPortExtn.dll相对于清单文件放置并将以下代码添加到manifest.json中

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

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

将这段代码放入您的JS(内容js\background js\extension js)中

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

有关更多信息,请参阅 https://developer.chrome.com/extensions/npapi.html

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

这篇关于如何从chrome扩展中调用DLL中的导出函数(使用C编写)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆