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
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Calling into a .dll
in Electron is no different to calling into one in plain NodeJS, which means you have two options, node-ffi or a native Node addon that 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.
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
回答2:
Electron-Edge helps to run .NET in Node.js on Electron.
You can find it on GitHub.
Here it 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...'