Name
Windows C++ Node.JS addon, that implements COM IDispatch object wrapper, analog ActiveXObject on cscript.exe
Features
-
Using ITypeInfo for conflict resolution between property and method (for example !rs.EOF not working without type information, becose need define EOF as an object)
-
Using optional parameters on constructor call
var con = "ADODB.Connection"activate: false // Allow activate existance object instance, false by defaultasync: true // Allow asynchronius calls, true by default (for future usage)type: true // Allow using type information, true by default;
- Create COM object from JS object and may be send as argument (for example send to Excel procedure)
var com_obj =text: test_valueobj: params: test_valuearr: test_value test_value test_value{ return v*2; };
- Additional dignostic propeties:
- __id - dispatch identity, for exmplae: ADODB.Connection.@Execute.Fields
- __value - value of dispatch object, equiles valueOf()
- __type - list member names with their properties
Usage example
Install package throw NPM (see below Building for details)
npm install winax
Create ADO Connection throw global function
;var con = 'ADODB.Connection';
Or using Object prototype
var winax = ;var con = 'ADODB.Connection';
Open connection and create simple table
con;con;con;con;con;
Select query and return RecordSet object
var rs = con;var reccnt = rsRecordCount;
Inspect RecordSet fields
var fields = rsFields;var fldcnt = fieldsCount;
Process records
rs;while !rsEOFvar name = value;var town = value;var phone = value;var zip = value;console;rs;
Or using fields by index
rs;while rsEOF != falsevar name = fields0value;var town = fields1value;var phone = fields2value;var zip = fields3value;console;rs;
Release COM objects (but other temporary objects may be keep references too)
winax
Tutorial and Examples
Building
This project uses Visual C++ 2013 (or later versions then support C++11 standard). Bulding also requires node-gyp and python 2.6 (or later) to be installed. You can do this with npm:
npm install -g node-gyp
To obtain and build use console commands:
git clone git://github.com/durs/node-axtivex.git
cd node-activex
node-gyp configure
node-gyp build
For Electron users, need rebuild with a different V8 version:
npm rebuild winax --runtime=electron --target=1.4.3 --disturl=https://atom.io/download/atom-shell --build-from-source
See also Electron Documentation: Using Native Node Modules
Tests
mocha is required to run unit tests.
npm install -g mocha
mocha test