Javascript 如何在 Electron App 中调用本地 .dll 文件
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/39567446/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to call local .dll files in Electron App
提问by batMan007
i have an issue how to call sample .dll files into my Electron App. I have sample .dll files in my folder, the thing is how to access my sample.dll file and how to call my sample.dll function and gets results. Any tutorials or steps to follow please sample code to start
我有一个问题,如何将示例 .dll 文件调用到我的 Electron 应用程序中。我的文件夹中有示例 .dll 文件,问题是如何访问我的 sample.dll 文件以及如何调用我的 sample.dll 函数并获取结果。任何教程或要遵循的步骤请示例代码开始
回答by Vadim Macagon
Calling into a .dll
in Electron is no different to calling into one in plain NodeJS, which means you have two options, node-ffior a native Node addonthat links with your .dll
and exposes a JavaScript API. If you decide to create a native Node addon you will need to build it to target Electron.
.dll
在 Electron 中调用 a与在普通 NodeJS 中调用 a没有什么不同,这意味着您有两个选项,node-ffi或与您链接并公开 JavaScript API的本机 Node 插件.dll
。如果您决定创建一个本地 Node 插件,您将需要构建它以针对 Electron。
Here are some links that cover these topics:
以下是一些涵盖这些主题的链接:
- node-ffi vs. node extension for accessing existing C++ functionality
- Call C++ library from Node.js (Node addons / node-ffi)
- https://github.com/node-ffi/node-ffi/wiki/Node-FFI-Tutorial
- https://blog.scottfrees.com/calling-native-c-dlls-from-a-node-js-web-app
- http://blog.scottfrees.com/building-an-asynchronous-c-addon-for-node-js-using-nan
回答by Pratik Singhal
Electron-Edge helps to run .NET in Node.js on Electron.
You can find it on GitHub.
Hereit is explained how to use dll files in it.(Scroll Down a little to find 'If you prefer to pre-compile your C# sources to a CLR assembly you can reference a CLR assembly from your Node.js code...'
Electron-Edge 有助于在 Electron 上的 Node.js 中运行 .NET。
您可以在 GitHub 上找到它。
这里解释了如何使用其中的 dll 文件。(向下滚动一点以找到“如果您更喜欢将 C# 源代码预编译为 CLR 程序集,您可以从 Node.js 代码中引用 CLR 程序集......”