I\'m trying to access a particular native Windows API call from within a node.js application. I believe that the best way to do this is to create a native extension / addon
This is now out of date. Today, use nan and node-gyp to write and build native modules that work across platforms.
I've gone through this pain myself. Here's a guide that helped me get it working. (PDF) Remember that since Node is now officially supported on Windows, Visual Studio is the recommended build tool for Node on Windows.
Basically:
D:\node\ with the location of your Node repo.I think node-ffi will help you. It's simple and it's works.
npm install ffi
var FFI = require('ffi');
function TEXT(text){
return new Buffer(text, 'ucs2').toString('binary');
}
var user32 = new FFI.Library('user32', {
'MessageBoxW': [
'int32', [ 'int32', 'string', 'string', 'int32' ]
]
});
var OK_or_Cancel = user32.MessageBoxW(
0, TEXT('I am Node.JS!'), TEXT('Hello, World!'), 1
);