你的位置:首页 > 软件开发 > Java > electron 使用 node

electron 使用 node

发布时间:2017-07-22 00:00:36
一、为什么需要使用DLL需要使用系统 API 操作或扩展应用程序;需要调用第三方的接口API,特别是与硬件设备进行通信,而这些接口 API 基本上都是通过 C++ 动态链接库(DLL)实现的;需要调用C++实现的一些复杂算法等。二、node-ffi 是什么node-ffi:N ...

electron 使用 node

一、为什么需要使用DLL

  • 需要使用系统 API 操作或扩展应用程序;
  • 需要调用第三方的接口API,特别是与硬件设备进行通信,而这些接口 API 基本上都是通过 C++ 动态链接库(DLL)实现的;
  • 需要调用C++实现的一些复杂算法等。

二、node-ffi 是什么

node-ffi:Node.js Foreign Function Interface

node-ffi is a Node.js addon for loading and calling dynamic libraries using pure JavaScript. It can be used to create bindings to native libraries without writing any C++ code. It also simplifies the augmentation of node.js with C code as it takes care of handling the translation of types across JavaScript and C, which can add reams of boilerplate code to your otherwise simple C. See the example/factorial for an example of this use case.

WARNING: node-ffi assumes you know what you're doing. You can pretty easily create situations where you will segfault the interpreter and unless you've got C debugger skills, you probably won't know what's going on.

上面是 node-ffi 的介绍,英语不好,就不翻译了。

三、electron 使用 node-ffi

使用上一篇文章里的项目,在 package.json 的 dependencies 节点上加上node-ffi 依赖:

"dependencies": {    "electron": "^1.6.11",    "ffi": "2.2.0"  }

原标题:electron 使用 node

关键词:

*特别声明:以上内容来自于网络收集,著作权属原作者所有,如有侵权,请联系我们: admin#shaoqun.com (#换成@)。

可能感兴趣文章

我的浏览记录