Electron通过ffi调用DLL

第一步建立一个DLL

int WINAPI CAM_Open(char *pIn, char* pOut);

第二步安装ffi

npm install --save ffi


针对electron版本重新编译

cd node_modules\ffi

node-gyp rebuild -target=1.6.11 -arch=x64 -dist-url=https://atom.io/download/atom-shell

cd node_modules\ref

node-gyp rebuild -target=1.6.11 -arch=x64 -dist-url=https://atom.io/download/atom-shell

第三步修改electron应用的index.html

<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>人脸识别测试程序</title>
</head>
<body>
<button id="CAMOpen" name="CAMOpen">调用人脸识别DLL</button>
</body>
<script>
    //var addon = require("facerecognitiondll")
    //document.write(addon.CAMOpen())

    var ffi = require("ffi")

    var DLL = ffi.Library('FaceRecognition.dll', {
        'CAM_Open' : ['int', ['string', 'string']]
    });

    var result = DLL.CAM_Open("", "");
    document.write("CAM_Open return "+ result)

</script>
</html>





评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值