Questions tagged [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 GitHub for more info: https://github.com/node-ffi/node-ffi.

npm package: https://www.npmjs.com/package/ffi. Note that the latest version of package is available as ffi, not node-ffi.

151 questions
128
votes
15 answers

Uncaught Error: Module did not self-register

I try to use node-vlc with nw.js (v0.12.0-alpha2). When i launch my app without nw.js it works, but when i launch it with nw.js i got an error: Uncaught Error: Module did not self-register.", source:…
Alexis Schad
  • 1,436
  • 2
  • 10
  • 8
26
votes
1 answer

node-ffi vs. node extension for accessing existing C++ functionality

I've got some existing C++ code that does numerical processing within a stand-alone C++ application. I now want to use that code within a new node.js application. Researching how to access C++ code from node.js, two options come up: Write a node.js…
pancake
  • 3,232
  • 3
  • 22
  • 35
15
votes
1 answer

Error while integrating node js code to cpp library

I am trying to node-ffi library to call a cpp code. CPP Code typedef struct{ char * key, char * value } ContextAttribute; typedef struct{ ContextAttribute * attribute, int count } Context; This is used in Status Init( …
AurA
  • 12,135
  • 7
  • 46
  • 63
14
votes
1 answer

Setting focus to a Windows application from Node-JS

I have a NodeJS application running on Windows that needs to display and switch the focus to a running Windows application when a user does a certain action. I have been using the node-ffi package to make windows API calls but have not been able to…
KeithTheBiped
  • 832
  • 10
  • 21
12
votes
2 answers

Node-webkit WinAPI

I’m developing simple node-webkit application for Windows (Vista, 7, …) and I need to use some WinAPI functions, specifically, RegisterHotKey and SendInput, to bind system-wide hotkeys and make keystrokes based on that. There’s no such API supplied…
dy_
  • 6,462
  • 5
  • 24
  • 30
11
votes
4 answers

How can I take a window screenshot in Node.js?

I'm in a research to find a way to take a screenshot of a window using Node.js, and I'm trying to do this with node-ffi, but I don't know how... at a time I'm stuck here: var ffi = require('ffi'); var user32 = new ffi.Library("user32", { …
11
votes
3 answers

C parser in Javascript

I'd like to parse C header files in Javascript. Is there any such library available? Otherwise, any tips to help me get started? Update: My ultimate goal is to automatically build interfaces for node-ffi. The parser doesn't necessarily have to be in…
Olivier Lalonde
  • 19,423
  • 28
  • 76
  • 91
10
votes
2 answers

Calling Rust from NodeJS

I was trying to build a simple rust rss 'harvester' for my soup.io blog and then post those entries to diaspora with node.js (since there is an npm package for that) I want to learn how to use rust from node so this is why I'm building this…
anderspree
  • 103
  • 1
  • 4
10
votes
4 answers

Call C++ library from Node.js (Node addons / node-ffi)

I'm trying to integrate an external C++ library (I have access to the .so file as well as the header files) into my Node.js application. After a lot of research my options are reduced to: Writing a Node addon Use node-ffi From node-ffi's…
Miki de Arcayne
  • 538
  • 1
  • 7
  • 15
8
votes
1 answer

Is it safe to pass a JavaScript callback to an FFI function which calls it in another thread?

I have a C function which takes a callback and invokes it on another thread: void call_in_new_thread(void (*callback)()) { // spawn a new thread and call `callback` in it ... } I want to call this function from JavaScript via Node-FFI, passing…
adam
  • 791
  • 6
  • 21
8
votes
1 answer

Is it possible to create an array of structs using ref-struct and ref-array?

I'm using node-ffi to call a function that takes an out-param as a pointer-to-a-pointer-to-an-array-of-structs. Is there a way to use ref-struct and ref-array for me to access the array that I get out? struct = require("ref-struct"); var rect_type…
dragonx
  • 14,963
  • 27
  • 44
7
votes
3 answers

Got Error "Dynamic Symbol Retrieval Error: Win32 error 127" when load DlL from nodejs

I want to load a dll file from node js. Here is the header file: #pragma once #ifdef __cplusplus #define EXAMPLE __declspec(dllexport) extern "C" { EXAMPLE int Add(int, int); } #endif In compile as, i choose "compile as C code" In active…
Kyuubi
  • 93
  • 1
  • 8
7
votes
2 answers

Node.js - Could not locate the bindings file

I'm trying to run an app of node-ffi on my windows 7 PC with Nodejs v6.2.0, but it crashes with the following error . I tried a variety of methods, but did not resolve my problem E:\iwork\workbase\myapp\node_modules\bindings\bindings.js:91…
Outlooks Chan
  • 71
  • 1
  • 1
  • 2
6
votes
2 answers

Why does npm install ffi return error. Using node version 12

I am new to nodejs. I am trying to call c++ API in a dll from node-js. So far I found that ffi can be used to do it. I followed the install instructions and installed the necessary build tools. But when I run npm install ffi I get the following…
Nikhil
  • 181
  • 1
  • 15
5
votes
2 answers

Why do EnumPrintersA and EnumPrintersW request the same amount of memory?

I call EnumPrintersA/EnumPrintersW functions using node-ffi to get list of local printers accessible from my PC. You should create the buffer which will be filled with information by EnumPrinters function. But you do not know the required size of…
Volodymyr Bezuglyy
  • 16,295
  • 33
  • 103
  • 133
1
2 3
10 11