javascript equivalent for python ctypes with node-gyp
<p>I want to transform a python script into a javascript script. My python script loads a dll and use its API.</p>

<pre><code>processings2D = ctypes.CDLL('processings2D.dll')
print(processings2D.ImageProcessor2DCreate())
</code></pre>

<p>I try do to the same with node-gyp but my script doesn't find the dll.</p>

<pre><code>console.log(processings2D.ImageProcessor2DCreate());
                      ^
TypeError: Cannot load processings2D.dll library
</code></pre>

<p>test.js</p>

<pre><code>var processings2D = require('./build/Release/processings2D.node');   
console.log(processings2D.ImageProcessor2DCreate());
</code></pre>

<p>addon.cc</p>

<pre><code>#include &lt;nan.h&gt;
#include "processings2D/processings2D.h"

HINSTANCE hDLL = NULL;
typedef int(*Fn)();

void ImageProcessor2DCreate(const Nan::FunctionCallbackInfo&lt;v8::Value&gt;&amp; info) {
    hDLL = LoadLibrary("processings2D.dll");
    if(!hDLL)
    {
        Nan::ThrowTypeError("Cannot load processings2D.dll library");
        return;
    }

    Fn fn = (Fn)GetProcAddress(hDLL, "ImageProcessor2DCreate");
    if (!fn) {
        Nan::ThrowTypeError("Could not load ImageProcessor2DCreate function");
        FreeLibrary(hDLL);
        return;
    }

    info.GetReturnValue().Set(Nan::New(fn()));
}

void Init(v8::Local&lt;v8::Object&gt; exports) {
    exports-&gt;Set(Nan::New("ImageProcessor2DCreate").ToLocalChecked(), Nan::New&lt;v8::FunctionTemplate&gt;(ImageProcessor2DCreate)-&gt;GetFunction());
}

NODE_MODULE(twoD, Init)
</code></pre>

<p>binding.gyp</p>

<pre><code>{
  "targets": [
    {
      "target_name": "processings2D",
      "sources": [
        "addon.cc"
      ],
      "include_dirs": [
        "&lt;!(node -e \"require('nan')\")"
      ]
    }
  ]
}
</code></pre>

<p>dll is in the Release folder <code>/build/Release/processings2D.dll</code></p>

<p><strong>Am I in the right direction ?</strong></p>