Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to call local .dll files in Electron App

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

like image 572
batMan007 Avatar asked Sep 19 '16 07:09

batMan007


People also ask

How do you call an Electron DLL?

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.

How do you load an Electron file?

Add a file(s) to this Electron application using the “Drag and Drop” feature as well as by manually displaying the file explorer (system) dialog to select one or multiple files. Display system notification when a file(s) is added. On application relaunch, display the list of files.

Can an Electron app run in browser?

As long as your main use of Electron is to create a 'native browser wrapper' for a web-app this is entirely possible. You'll probably have to step through your application and disable Electron specific functionality at multiple places.


2 Answers

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
like image 101
Vadim Macagon Avatar answered Nov 01 '22 09:11

Vadim Macagon


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...'

like image 29
Pratik Singhal Avatar answered Nov 01 '22 08:11

Pratik Singhal