### Complete WScript Script Example Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md A full example demonstrating object creation, file system enumeration, and script termination. ```javascript // example.js - Windows Script Host-style script WScript.Echo('WScript Example'); WScript.Echo('Arguments: ' + WScript.Arguments.Count); // Create FileSystemObject var fso = WScript.CreateObject('Scripting.FileSystemObject'); // Check if folder exists var folderPath = 'C:\\Temp'; if (fso.FolderExists(folderPath)) { WScript.Echo('Folder exists'); // List files var folder = fso.GetFolder(folderPath); var files = folder.Files; var e = new Enumerator(files); while (!e.atEnd()) { var file = e.item(); WScript.Echo('File: ' + file.Name + ' (' + file.Size + ' bytes)'); e.moveNext(); } } else { WScript.Echo('Folder does not exist'); } // Clean up WScript.Echo('Done'); WScript.Quit(0); ``` -------------------------------- ### Install build prerequisites Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Global installation of Windows build tools required for compilation. ```bash npm install --global windows-build-tools ``` -------------------------------- ### Install windows-build-tools Source: https://github.com/durs/node-activex/blob/master/README.md Install the necessary build tools for Windows environments via npm. ```bash npm install --global --production windows-build-tools ``` -------------------------------- ### Advise Event Sink Example Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Example of creating an event sink and advising it to a connection point. ```javascript const winax = require('winax'); const excel = new winax.Object('Excel.Application'); // Create event sink const eventSink = { onWorkbookOpen: function(workbook) { console.log('Workbook opened'); } }; // Get connection point (if supported) const connPoint = excel.__ConnectionPoints; if (connPoint) { const cookie = connPoint.Advise(eventSink); console.log('Event sink advised with cookie:', cookie); } ``` -------------------------------- ### Clone and build project Source: https://github.com/durs/node-activex/blob/master/README.md Standard commands to clone the repository and install dependencies. ```bash git clone git://github.com/durs/node-axtivex.git cd node-activex npm install ``` -------------------------------- ### Install winax from source Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Use these commands to install the package from source, optionally specifying a Visual Studio version. ```bash npm install winax --build-from-source ``` ```bash npm install winax --msvs_version=2017 ``` -------------------------------- ### Install node-activex Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Command to install the winax package via npm. ```bash npm install winax ``` -------------------------------- ### Create ADO Connection Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Example of initializing an ADODB connection and setting properties. ```javascript const winax = require('winax'); const connection = new winax.Object('ADODB.Connection'); connection.ConnectionString = 'Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\\data;'; connection.Open(); ``` -------------------------------- ### Create basic variants Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Variant.md Examples of initializing variants with specific primitive types. ```javascript const winax = require('winax'); const v1 = new winax.Variant(17, 'short'); const v2 = new winax.Variant(3.14, 'float'); const v3 = new winax.Variant('text', 'string'); ``` -------------------------------- ### Perform a debug build Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Install the package with debug flags enabled. ```bash npm install --debug ``` -------------------------------- ### Install winax package Source: https://github.com/durs/node-activex/blob/master/README.md Commands to install the winax package via NPM, optionally specifying MSVC versions. ```bash npm install winax npm install winax --msvs_version=2015 npm install winax --msvs_version=2017 ``` -------------------------------- ### Specify Visual Studio version Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Install the package targeting a specific Visual Studio version. ```bash npm install winax --msvs_version=2015 npm install winax --msvs_version=2017 npm install winax --msvs_version=2019 ``` -------------------------------- ### Run unit tests with Mocha Source: https://github.com/durs/node-activex/blob/master/README.md Install the Mocha test framework globally and execute the test suite with garbage collection exposed. ```bash npm install -g mocha mocha --expose-gc test ``` -------------------------------- ### Unadvise Event Sink Example Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Example of disconnecting an event sink using the advice cookie. ```javascript const cookie = connPoint.Advise(eventSink); // Later, disconnect the event sink const disconnected = connPoint.Unadvise(cookie); if (disconnected) { console.log('Event sink disconnected'); } ``` -------------------------------- ### Create reference type variants Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Variant.md Examples of creating variants that reference other variants or use pointer prefix syntax. ```javascript const v_short = new winax.Variant(17, 'short'); const v_ref = new winax.Variant(v_short, 'byref'); const v_pref = new winax.Variant(17, 'pshort'); // Prefix syntax ``` -------------------------------- ### Create type-safe variant arrays Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Variant.md Examples of initializing variants using JavaScript arrays. ```javascript const shortArray = new winax.Variant([1, 2, 3], 'short'); const stringArray = new winax.Variant(['a', 'b', 'c'], 'string'); ``` -------------------------------- ### Excel Application Method Calls Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Example of automating Excel by creating an application object, adding workbooks, and manipulating cells. ```javascript const excel = new winax.Object('Excel.Application'); const workbook = excel.Workbooks.Add(); const worksheet = workbook.Worksheets.Item(1); worksheet.Range('A1').Value = 'Hello'; workbook.Save(); excel.Quit(); ``` -------------------------------- ### Constructing Variant Arrays Source: https://github.com/durs/node-activex/blob/master/_autodocs/types.md Examples of creating 1D, 2D, and 3D arrays using the winax.Variant constructor for SAFEARRAY support. ```javascript // 1D array const arr1d = new winax.Variant([1, 2, 3]); // 2D array (Excel ranges) const arr2d = new winax.Variant([ [10, 20, 30], [40, 50, 60] ]); // 3D array (if supported by COM object) const arr3d = new winax.Variant([ [[1, 2], [3, 4]], [[5, 6], [7, 8]] ]); ``` -------------------------------- ### Implementation Workflow Source: https://github.com/durs/node-activex/blob/master/_autodocs/README.md Recommended steps for implementing tasks using the node-activex library. ```text 1. Find your task in QUICK_REFERENCE.md 2. Follow the code example provided 3. Consult specific API reference if needed 4. Check error handling in errors.md ``` -------------------------------- ### Build the project Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Commands to build the project from source. ```bash npm install # or node-gyp configure node-gyp build ``` -------------------------------- ### Configure ActiveXObject options Source: https://github.com/durs/node-activex/blob/master/_autodocs/types.md Demonstrates various ways to instantiate COM objects using different configuration options. ```javascript const winax = require('winax'); // Default options (type information enabled) const conn = new winax.Object('ADODB.Connection'); // Activate existing instance const excel = new winax.Object('Excel.Application', { activate: true }); // Disable type information (not recommended) const obj = new winax.Object('SomeProgId', { type: false }); // Combine options const shell = new winax.Object('WScript.Shell', { activate: false, getobject: false, type: true }); ``` -------------------------------- ### Build with node-gyp Source: https://github.com/durs/node-activex/blob/master/README.md Manual build process using node-gyp commands. ```bash npm install -g node_gyp node-gyp configure node-gyp build node-gyp rebuild ``` -------------------------------- ### Create Object with Options Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Instantiate a COM object with specific configuration flags. ```javascript const shell = new winax.Object('WScript.Shell', { activate: false, type: true }); ``` -------------------------------- ### Initialize ActiveXObject with Options Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Configures a new COM object instance using specific activation and type information settings. ```javascript const obj = new winax.Object('ProgID', { activate: false, getobject: false, type: true }); ``` -------------------------------- ### Get string representation with toString() Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Obtain a human-readable string representation of the dispatch object. ```javascript const obj = new winax.Object('Shell.BrowserViewFolderEvents'); console.log(obj.toString()); // Outputs human-readable representation ``` -------------------------------- ### Initialize ActiveXObject with Options Source: https://github.com/durs/node-activex/blob/master/README.md Configure the ActiveXObject constructor with specific activation and type information settings. ```js var con = new ActiveXObject("Object.Name", { activate: false, // Allow activate existance object instance (through CoGetObject), false by default getobject: false, // Allow using name of the file in the ROT (through GetAccessibleObject), false by default type: true // Allow using type information, true by default }); ``` -------------------------------- ### Open Connection and Create Table Source: https://github.com/durs/node-activex/blob/master/README.md Opens a database connection and executes SQL commands to create and populate a table. ```javascript con.Open('Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\tmp;Extended Properties="DBASE IV;"', '', ''); con.Execute("Create Table persons.dbf (Name char(50), City char(50), Phone char(20), Zip decimal(5))"); con.Execute("Insert into persons.dbf Values('John', 'London','123-45-67','14589')"); con.Execute("Insert into persons.dbf Values('Andrew', 'Paris','333-44-55','38215')"); con.Execute("Insert into persons.dbf Values('Romeo', 'Rom','222-33-44','54323')"); ``` -------------------------------- ### Launch WScript Scripts via CLI Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Commands to execute WScript-compatible scripts using the nodewscript binary. ```bash nodewscript script.js [arguments...] ``` ```bash npm install -g winax nodewscript my_script.js arg1 arg2 ``` -------------------------------- ### Advise Event Sink Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Method signature for establishing a connection with an event sink. ```javascript Advise(eventSink: Object | Function): number ``` -------------------------------- ### cp.Advise(sink) Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Establishes a connection between a sink object and a connection point, returning a cookie used for disconnection. ```APIDOC ## Advise ### Description Connects a sink object to the connection point to begin receiving events. ### Parameters - **sink** (Object) - Required - The object containing event handler methods. ### Returns - **cookie** (Number) - A unique identifier for the connection, used for Unadvise. ``` -------------------------------- ### Advise(eventSink) Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Establishes a connection between the connection point and an event sink to receive event notifications. ```APIDOC ## Advise(eventSink) ### Description Establishes a connection between this connection point and an event sink. After advising, the sink receives event notifications. ### Parameters - **eventSink** (Object | Function) - Required - Event sink object with event handler methods or a function wrapper. ### Returns - **number** - Advice cookie (DWORD) used to later unadvise the connection. ### Throws - **Error** - If advising fails (e.g., sink doesn't implement required interface). ``` -------------------------------- ### Initialize Variant objects Source: https://github.com/durs/node-activex/blob/master/_autodocs/types.md Demonstrates creating Variant instances with specific types, including reference types and arrays. ```javascript const winax = require('winax'); // Typed values const i = new winax.Variant(42, 'int'); const s = new winax.Variant('hello', 'string'); const d = new winax.Variant(new Date(), 'date'); // Reference types const ref = new winax.Variant(10, 'pint'); // Prefix syntax const byref = new winax.Variant(10, 'byref'); // Arrays const ints = new winax.Variant([1, 2, 3], 'int'); const strings = new winax.Variant(['a', 'b'], 'string'); ``` -------------------------------- ### Manage ADO connection with cleanup Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Establishing a database connection and ensuring resources are released. ```javascript const winax = require('winax'); try { const connection = new winax.Object('ADODB.Connection', { type: true }); connection.ConnectionString = 'Provider=MSOLEDBSQL;...'; connection.Open(); // Use connection... } catch(e) { console.error('Database error:', e.message); } finally { winax.release(connection); } ``` -------------------------------- ### Instantiate COM objects via ActiveXObject Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Module.md Demonstrates creating COM objects using ProgIDs or JavaScript objects for event handling. ```javascript require('winax'); // Global ActiveXObject is now available const shell = new ActiveXObject('WScript.Shell'); const fso = new ActiveXObject('Scripting.FileSystemObject'); // Create from JavaScript object const handler = new ActiveXObject({ onEvent: function(data) { console.log(data); } }); ``` -------------------------------- ### Configuring Constructor Options Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Define behavior for object instantiation using an options object. ```javascript { activate: boolean, // Activate existing instance (default: false) getobject: boolean, // Allow ROT lookup (default: false) type: boolean // Use type info (default: true) } ``` -------------------------------- ### Initialize Object Constructor Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Syntax for creating a new COM object wrapper. ```javascript new Object(id: string | Record, options?: ActiveXObjectOptions) ``` -------------------------------- ### Troubleshooting Workflow Source: https://github.com/durs/node-activex/blob/master/_autodocs/README.md Recommended steps for resolving issues encountered while using the library. ```text 1. Check QUICK_REFERENCE.md troubleshooting section 2. Look up error code in errors.md 3. Review error handling patterns in errors.md 4. Check specific API docs for your operation ``` -------------------------------- ### Activate Existing COM Instance Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Connects to an already running application instance if available. ```javascript const winax = require('winax'); // If Excel is already running, connect to it; otherwise create new const excel = new winax.Object('Excel.Application', { activate: true }); ``` -------------------------------- ### Project Documentation File Structure Source: https://github.com/durs/node-activex/blob/master/_autodocs/GENERATION_REPORT.md A directory tree showing the organization of the generated documentation files. ```text output/ ├── README.md ← Start here ├── INDEX.md ← Navigation hub ├── QUICK_REFERENCE.md ← Quick lookup ├── types.md ← Type reference ├── configuration.md ← Config guide ├── errors.md ← Error reference ├── wscript-api.md ← WScript guide ├── GENERATION_REPORT.md ← This file └── api-reference/ ├── Object.md ← COM objects ├── Variant.md ← Variants ├── Module.md ← Module functions └── ConnectionPointObject.md ← Events ``` -------------------------------- ### Use WScript compatibility mode Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Enabling global ActiveXObject and WScript emulation. ```javascript require('winax'); // Global objects are now available const shell = new ActiveXObject('WScript.Shell'); const fso = new ActiveXObject('Scripting.FileSystemObject'); // WScript emulation WScript.Echo('Starting...'); WScript.Sleep(1000); // Cleanup winax.release(shell, fso); ``` -------------------------------- ### Creating COM Objects Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Module.md Defines the signature for the Object constructor and demonstrates creating an Excel application instance. ```javascript Object(id: string | Record, options?: ActiveXObjectOptions): Object ``` ```javascript const winax = require('winax'); const excel = winax.Object('Excel.Application'); // Equivalent to: new winax.Object('Excel.Application') ``` -------------------------------- ### Migrating Event Handling Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Demonstrates connecting event handlers to ActiveX objects in both environments. ```vbscript Set shell = CreateObject("WScript.Shell") WScript.ConnectObject shell, "Shell_" Sub Shell_KeyDown(key, shift) WScript.Echo "Key pressed" End Sub ``` ```javascript var shell = WScript.CreateObject('WScript.Shell'); function Shell_KeyDown(key, shift) { WScript.Echo('Key pressed'); } WScript.ConnectObject(shell, 'Shell_'); ``` -------------------------------- ### Define Constructor Configuration Options Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Defines the configuration object structure for controlling COM object creation behavior. ```javascript { activate: boolean, // Activate existing instance getobject: boolean, // Allow ROT lookup type: boolean // Use type information } ``` -------------------------------- ### Instantiate ConnectionPointObject Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Constructor signature for creating a new connection point wrapper. ```javascript new ConnectionPointObject(connectionPoint: IConnectionPoint, dispatch: IDispatch) ``` -------------------------------- ### Creating COM Objects Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Instantiate COM objects using the module constructor, global ActiveXObject, or wrap JavaScript objects. ```javascript // Using module const excel = new winax.Object('Excel.Application'); // Using global (after require) const word = new ActiveXObject('Word.Application'); // With options const shell = new winax.Object('WScript.Shell', { activate: false, getobject: false, type: true }); // Wrapping JavaScript objects const handler = new winax.Object({ onEvent: function(data) { console.log(data); } }); ``` -------------------------------- ### WScript.CreateObject(progId, eventPrefix) Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Creates a COM object instance. ```APIDOC ## WScript.CreateObject(progId, eventPrefix) ### Description Creates a COM object with optional event connection. ### Parameters - **progId** (string) - Required - COM component ProgID - **eventPrefix** (string) - Optional - Prefix for event handler names ### Returns - **Object** - Created COM object wrapper ``` -------------------------------- ### WScript.Echo Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Outputs a message to the console. ```APIDOC ## WScript.Echo(message) ### Description Displays a message string. ### Parameters - **message** (string) - Required - The message to output. ``` -------------------------------- ### Initialize winax and use global ActiveXObject Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Module.md Requires the winax module to enable the global ActiveXObject constructor for COM object instantiation. ```javascript require('winax'); // After require, ActiveXObject is globally available const obj = new ActiveXObject('Excel.Application'); ``` -------------------------------- ### Wrap JavaScript Object with Methods Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Create a COM-compatible wrapper containing functions and properties. ```javascript const eventHandler = new winax.Object({ onCompleted: function(result) { console.log('Task completed with: ' + result); }, timeout: 5000 }); ``` -------------------------------- ### Create New COM Instance Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Instantiates a new COM object process. Each call creates a separate instance. ```javascript const excel1 = new winax.Object('Excel.Application'); const excel2 = new winax.Object('Excel.Application'); // excel1 and excel2 are separate processes ``` -------------------------------- ### Creating COM Objects Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Instantiate COM objects using the winax.Object constructor or the global ActiveXObject, with support for configuration options and wrapping JavaScript objects. ```APIDOC ## new winax.Object(progid, [options]) ### Description Creates a new COM object instance. Optionally accepts an options object to configure activation, object retrieval, and type handling. ### Parameters - **progid** (string) - Required - The programmatic identifier of the COM object. - **options** (object) - Optional - Configuration object (e.g., { activate: boolean, getobject: boolean, type: boolean }). ### Example const excel = new winax.Object('Excel.Application'); const shell = new winax.Object('WScript.Shell', { activate: false, getobject: false, type: true }); ``` -------------------------------- ### Accessing ADO Databases Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Demonstrates opening a connection and iterating through a recordset. Ensure winax.release is called to prevent memory leaks. ```javascript const con = new winax.Object('ADODB.Connection'); con.Open('connection_string'); const rs = con.Execute('SELECT * FROM table'); rs.MoveFirst(); while (!rs.EOF) { console.log(rs.Fields('Name').Value); rs.MoveNext(); } winax.release(rs, con); ``` -------------------------------- ### winax.Object Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Instantiation of ActiveX objects. ```APIDOC ## winax.Object ### Description Creates an instance of an ActiveX object by its ProgID. ### Constructor - `new winax.Object(progId, [options])` ### Parameters - **progId** (string) - The programmatic identifier of the ActiveX object (e.g., 'Excel.Application'). - **options** (object) - Optional configuration, such as `{ activate: true }`. ``` -------------------------------- ### winax.Object Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Constructor for creating a new COM object. ```APIDOC ## new winax.Object(id, options) ### Description Creates a new COM object instance. ### Parameters - **id** (string) - Required - The ProgID or CLSID of the COM object. - **options** (object) - Optional - Configuration options for the object. ``` -------------------------------- ### Configure binding.gyp for node-activex Source: https://github.com/durs/node-activex/blob/master/README.md Add this dependency to your binding.gyp file to link against the node-activex library. ```json "dependencies": [ ") - Required - ProgID string or JavaScript object - **options** (ActiveXObjectOptions) - Optional - Configuration options ### Returns - **Type**: Object - **Description**: COM object wrapper ### Example ```javascript require('winax'); const shell = new ActiveXObject('WScript.Shell'); const handler = new ActiveXObject({ onEvent: function(data) { console.log(data); } }); ``` ``` -------------------------------- ### Migrating File System Operations Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Illustrates file existence checks and object retrieval using FileSystemObject. ```vbscript Set fso = CreateObject("Scripting.FileSystemObject") If fso.FileExists("C:\file.txt") Then Set file = fso.GetFile("C:\file.txt") End If ``` ```javascript var fso = new ActiveXObject('Scripting.FileSystemObject'); if (fso.FileExists('C:\\file.txt')) { var file = fso.GetFile('C:\\file.txt'); } ``` -------------------------------- ### Running WScript Mode Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Execute scripts using the nodewscript command-line tool. ```bash nodewscript script.js ``` -------------------------------- ### Create COM Object Instance Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Instantiate a COM object using its ProgID. ```javascript const winax = require('winax'); const excel = new winax.Object('Excel.Application', { activate: true }); ``` -------------------------------- ### Initialize ADO Connection Source: https://github.com/durs/node-activex/blob/master/README.md Methods to initialize an ADO connection using either the global ActiveXObject or the winax object prototype. ```javascript require('winax'); var con = new ActiveXObject('ADODB.Connection'); ``` ```javascript var winax = require('winax'); var con = new winax.Object('ADODB.Connection'); ``` -------------------------------- ### winax.Object Constructor Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Instantiates a new ActiveX object using a ProgID and optional configuration settings. ```APIDOC ## new winax.Object(progID, options) ### Description Creates a new instance of an ActiveX object. ### Parameters - **progID** (string) - Required - The Program ID of the ActiveX object to instantiate. - **options** (Object) - Optional - Configuration object for the instance. ### Options - **activate** (boolean) - Optional - Activate existing instance (default: false). - **getobject** (boolean) - Optional - Allow ROT lookup (default: false). - **type** (boolean) - Optional - Use type info (default: true). ``` -------------------------------- ### Rebuild using electron-rebuild Source: https://github.com/durs/node-activex/blob/master/README.md Alternative method to rebuild using the electron-rebuild module. ```bash npm install --save-dev @electron/rebuild .\node_modules\.bin\electron-rebuild.cmd ``` -------------------------------- ### Basic ActiveX Object Lifecycle Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Standard pattern for importing, creating, using, and releasing an ActiveX object. ```javascript const winax = require('winax'); const obj = new winax.Object('ProgID'); obj.Property = value; obj.Method(); winax.release(obj); ``` -------------------------------- ### Manage COM Object Lifecycle Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Use try-finally blocks to ensure resources are released, release objects in dependency order, and avoid using references after release. ```javascript // Always use try-finally const obj = new winax.Object('SomeProgID'); try { // Use object } finally { winax.release(obj); } // Release in dependency order winax.release(fields, recordset, connection); // Avoid storing references after release const ref = obj; winax.release(obj); // ref is now invalid ``` -------------------------------- ### List String and Data Types Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Displays supported string, date, currency, decimal, and variant types. ```text 'string' (Unicode BSTR), 'date' (OLE Date), 'currency' (fixed decimal), 'decimal' (high precision), 'variant' (generic) ``` -------------------------------- ### Execute WScript with nodewscript Source: https://github.com/durs/node-activex/blob/master/README.md Command line usage for executing a JScript file using the global nodewscript command. ```bash nodewscript [options] ``` -------------------------------- ### Access WScript FullName Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Retrieves the full path to the WScript executable. ```javascript WScript.FullName: string ``` -------------------------------- ### Initialize Variant constructor Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Variant.md Syntax for creating a new Variant instance with an optional value and type. ```javascript new Variant(value?: any, type?: VariantType) ``` -------------------------------- ### Reference Navigation Source: https://github.com/durs/node-activex/blob/master/_autodocs/README.md Recommended path for browsing the documentation for reference purposes. ```text 1. Start with INDEX.md for overview 2. Browse api-reference/ for class details 3. Use types.md for type information 4. Use configuration.md for options ``` -------------------------------- ### new Object(id, options) Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Creates and returns a new COM object wrapper. This constructor supports creating instances from a ProgID or wrapping a JavaScript object for use as a COM object. ```APIDOC ## new Object(id, options) ### Description Creates and returns a new COM object wrapper. Supports two usage patterns: creating a new COM object from a ProgID or wrapping a JavaScript object. ### Parameters #### Path Parameters - **id** (string | Record) - Required - ProgID or class identifier (e.g., 'Excel.Application') or a JavaScript object to wrap. - **options** (ActiveXObjectOptions) - Optional - Configuration options controlling object creation behavior. #### Options - **activate** (boolean) - Optional - Allow activation of existing object instance via CoGetObject. - **getobject** (boolean) - Optional - Allow using the name as a file path in the ROT via GetAccessibleObject. - **type** (boolean) - Optional - Enable type information lookup via ITypeInfo. ### Returns - **Object** - A new COM object wrapper instance. ### Throws - **TypeError** - If the ProgID is invalid or the COM object cannot be created. - **Error** - If COM initialization fails or object is not available. ``` -------------------------------- ### Access and Iterate COM Collections Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Demonstrates accessing COM collection items via index and iterating through them. Note that COM collections are typically 1-indexed. ```javascript const collection = comObject.Items; // Returns a collection const first = collection(0); // Get first item (1-indexed in COM) const byIndex = collection[1]; // Bracket notation also works // Iterate over collection for (let i = 0; i < collection.Count; i++) { const item = collection(i); // Use item } ``` -------------------------------- ### Accessing COM Object Properties Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Demonstrates retrieving property values using dot notation, index access, or bracket notation. ```javascript const value = comObject.PropertyName; const byIndex = comObject[0]; const byKey = comObject['KeyName']; ``` -------------------------------- ### Automating Excel Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Shows how to instantiate Excel, manipulate worksheets, and save workbooks. Always call winax.release on the application object. ```javascript const excel = new winax.Object('Excel.Application', { activate: true }); excel.Visible = true; const wb = excel.Workbooks.Add(); const ws = wb.Worksheets(1); ws.Range('A1').Value = 'Data'; wb.Save(); excel.Quit(); winax.release(excel); ``` -------------------------------- ### ActiveXObject Constructor Source: https://github.com/durs/node-activex/blob/master/README.md Creates a new COM object instance or wraps an existing one with specific configuration options. ```APIDOC ## new ActiveXObject(progID, options) ### Description Creates a new COM object instance or wraps an existing one based on the provided ProgID and configuration options. ### Parameters - **progID** (string) - Required - The programmatic identifier of the COM object. - **options** (object) - Optional - Configuration object: - **activate** (boolean) - Allow activation of an existing object instance (default: false). - **getobject** (boolean) - Allow using the name of a file in the ROT (default: false). - **type** (boolean) - Allow using type information (default: true). ### Example ```js var con = new ActiveXObject("Object.Name", { activate: false, getobject: false, type: true }); ``` ``` -------------------------------- ### Configure connection points for events Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Establish and disconnect event sinks using the __ConnectionPoints interface. ```javascript const source = new winax.Object('EventSource.Program'); const sink = { onEvent: function(data) { // Handler implementation } }; // Establish event connection const connPoint = source.__ConnectionPoints; const cookie = connPoint.Advise(sink); // Later disconnect connPoint.Unadvise(cookie); ``` -------------------------------- ### Iterate COM Collections with Enumerator Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Constructor and iteration pattern for traversing COM collections using WScript-style methods. ```javascript new Enumerator(collection: Object) ``` ```javascript var shell = new ActiveXObject('WScript.Shell'); var envVars = shell.Environment('PROCESS'); var e = new Enumerator(envVars); for (; !e.atEnd(); e.moveNext()) { WScript.Echo(e.item()); } ``` -------------------------------- ### Access WScript BuildVersion Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Retrieves the build version number. ```javascript WScript.BuildVersion: string ``` ```javascript console.log(WScript.BuildVersion); // "6.0" ``` -------------------------------- ### Manage multiple COM event sources Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Shows how to establish and disconnect multiple event connections simultaneously for different COM objects. ```javascript const winax = require('winax'); const excel = new winax.Object('Excel.Application'); const workbook = excel.Workbooks.Add(); const worksheet = workbook.Worksheets(1); // Application events const appEvents = excel.__ConnectionPoints; const appCookie = appEvents.Advise({ workbookOpen: function(wb) { console.log('WB Open'); } }); // Workbook events const wbEvents = workbook.__ConnectionPoints; const wbCookie = wbEvents.Advise({ worksheetActivate: function(ws) { console.log('WS Active'); } }); // Later disconnect both appEvents.Unadvise(appCookie); wbEvents.Unadvise(wbCookie); ``` -------------------------------- ### winax.release Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Resource management for ActiveX objects. ```APIDOC ## winax.release ### Description Explicitly releases ActiveX objects to free system resources. It is recommended to release objects in reverse dependency order. ### Usage - `winax.release(obj)`: Releases a single object. - `winax.release(obj1, obj2, ...)`: Releases multiple objects. ``` -------------------------------- ### Access WScript Version Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Retrieves the version string of the WScript implementation. ```javascript WScript.Version: string ``` ```javascript console.log(WScript.Version); // "Windows / Node Script Host" ``` -------------------------------- ### Connect to COM objects globally Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Utilize the global WScript.ConnectObject approach when operating in WScript mode. ```javascript require('winax'); global.WScript.ConnectObject(comObject, 'prefix_'); // Later calls omit the connection point object: global.WScript.DisconnectObject(comObject); ``` -------------------------------- ### Automate Excel Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Create an Excel instance, manipulate workbooks and worksheets, and save changes. ```javascript const excel = new winax.Object('Excel.Application', { activate: true }); excel.Visible = true; const wb = excel.Workbooks.Add(); const ws = wb.Worksheets(1); ws.Range('A1').Value = 'Hello'; ws.Range('B1').Value = 42; wb.Save(); excel.Quit(); winax.release(excel); ``` -------------------------------- ### Initialize Currency and Decimal Types Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Variant.md Specify 'currency' or 'decimal' types when initializing Variants to ensure appropriate precision for financial calculations. ```javascript const winax = require('winax'); // Currency (fixed-point with 4 decimal places) const price = new winax.Variant(19.99, 'currency'); // Decimal (higher precision) const amount = new winax.Variant(1234.5678, 'decimal'); ``` -------------------------------- ### Access connection point methods Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Module.md Indicates that connection point methods become available after creating a COM object that supports event binding. ```javascript // After Object creation, connection point methods are available // (see ConnectionPointObject documentation) ``` -------------------------------- ### Instantiate COM Object Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Wraps a COM IDispatch interface to enable interaction with Windows COM objects. ```javascript const winax = require('winax'); const excel = new winax.Object('Excel.Application'); ``` -------------------------------- ### Importing node-activex Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Import the module to enable ActiveXObject globally. ```javascript const winax = require('winax'); ``` -------------------------------- ### Perform File System operations Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Use the Scripting.FileSystemObject to check for folders and iterate through files. ```javascript const fso = new winax.Object('Scripting.FileSystemObject'); if (fso.FolderExists('C:\\folder')) { const files = fso.GetFolder('C:\\folder').Files; for (let i = 0; i < files.Count; i++) { console.log(files(i).Name); } } winax.release(fso); ``` -------------------------------- ### ActiveXObjectOptions Source: https://github.com/durs/node-activex/blob/master/_autodocs/types.md Configuration options passed to the winax.Object constructor to control COM object creation behavior. ```APIDOC ## ActiveXObjectOptions ### Description Configuration options passed to the winax.Object constructor to control COM object creation behavior. ### Fields - **activate** (boolean) - Optional - When true, allows activating existing COM object instances using CoGetObject. Default: false. - **getobject** (boolean) - Optional - When true, allows using the ProgID string as a moniker path to access objects in the ROT via GetAccessibleObject. Default: false. - **type** (boolean) - Optional - When true, uses COM type information (ITypeInfo) for conflict resolution between properties and methods. Default: true. ### Usage Example ```javascript const winax = require('winax'); // Activate existing instance const excel = new winax.Object('Excel.Application', { activate: true }); // Combine options const shell = new winax.Object('WScript.Shell', { activate: false, getobject: false, type: true }); ``` ``` -------------------------------- ### ActiveXObject Constructor Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Creates a COM object by its ProgID, following standard VBScript syntax. ```APIDOC ## new ActiveXObject(progId, eventPrefix) ### Description Creates a COM object by ProgID. Identical to `new winax.Object()` but follows VBScript syntax. ### Parameters - **progId** (string) - Required - COM component ProgID (e.g., 'Excel.Application') - **eventPrefix** (string) - Optional - Optional prefix for event handler methods when auto-connecting events ### Example ```javascript var shell = new ActiveXObject('WScript.Shell'); var excel = new ActiveXObject('Excel.Application'); ``` ``` -------------------------------- ### Migrating ADO Database Access Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Shows the transition from CreateObject to ActiveXObject for ADODB connections. ```vbscript Set con = CreateObject("ADODB.Connection") con.Open "Provider=MSOLEDBSQL;Server=localhost;Database=db" Set rs = con.Execute("SELECT * FROM users") ``` ```javascript var con = new ActiveXObject('ADODB.Connection'); con.Open('Provider=MSOLEDBSQL;Server=localhost;Database=db'); var rs = con.Execute('SELECT * FROM users'); ``` -------------------------------- ### Rebuild for Electron Source: https://github.com/durs/node-activex/blob/master/README.md Rebuild the native module to match the specific V8 version used by Electron. ```bash npm rebuild winax --runtime=electron --target=41.1.0 --arch=x64 --dist-url=https://electronjs.org/headers ``` -------------------------------- ### Default Constructor Behavior Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Demonstrates that omitting the options object defaults to specific settings. ```javascript // These are equivalent const obj1 = new winax.Object('Excel.Application'); const obj2 = new winax.Object('Excel.Application', { activate: false, getobject: false, type: true }); ``` -------------------------------- ### Accessing Properties in VBScript and Node.js Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Demonstrates the difference between VBScript implicit property access and explicit Node.js calls. ```vbscript ' VBScript (works) If shell.SpecialFolders("Desktop") Then '... End If ``` ```javascript // Node.js (use explicit call) if (shell.SpecialFolders('Desktop')) { // ... } ``` -------------------------------- ### Create COM Object Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Creates a COM object, optionally connecting events using a prefix. ```javascript WScript.CreateObject(progId: string, eventPrefix?: string): Object ``` ```javascript var fso = WScript.CreateObject('Scripting.FileSystemObject'); var shell = WScript.CreateObject('WScript.Shell'); ``` -------------------------------- ### WScript.ConnectObject(object, eventPrefix) Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Connects event handlers to a COM object. ```APIDOC ## WScript.ConnectObject(object, eventPrefix) ### Description Connects event handlers from the current script context to a COM object. Event methods in the script should be named with the given prefix. ### Parameters - **object** (Object) - Required - COM object supporting events - **eventPrefix** (string) - Required - Prefix for event handler function names ``` -------------------------------- ### WScript.Arguments Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Provides access to command-line arguments passed to the script. ```APIDOC ## WScript.Arguments ### Description Provides access to the collection of command-line arguments passed to the script. ### Properties - **Count** (number) - The total number of arguments. ### Methods - **Item(index)** (string) - Returns the argument at the specified 0-based index. - **(index)** (string) - Returns the argument at the specified 0-based index using shorthand syntax. ``` -------------------------------- ### Create COM Object via File Path Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Retrieves an object from the Running Object Table using a file path and the getobject option. ```javascript const file = new winax.Object('C:\\Documents\\file.docx', { getobject: true }); ``` -------------------------------- ### List Integer Type Aliases Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Displays the available aliases for 8, 16, 32, and 64-bit signed and unsigned integers. ```text 'int', 'uint', 'int8'/'char', 'uint8'/'byte', 'int16'/'short', 'uint16', 'int32', 'uint32', 'int64'/'long', 'uint64' ``` -------------------------------- ### Handle COM events with ConnectionPointObject Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Demonstrates creating an Excel application, defining an event sink object, and managing the event connection lifecycle. ```javascript const winax = require('winax'); // Create Excel application const excel = new winax.Object('Excel.Application', { activate: true }); excel.Visible = true; // Define event sink with handler methods const eventHandlers = { workbookOpen: function(wb) { console.log('Workbook opened: ' + wb.Name); }, sheetActivate: function(sheet) { console.log('Sheet activated: ' + sheet.Name); }, sheetChange: function(sheet, target) { console.log('Cell changed in: ' + target.Address); } }; // Establish event connection try { // Get application events const appEvents = excel.__ConnectionPoints; if (appEvents) { const cookie = appEvents.Advise(eventHandlers); console.log('Events connected'); // ... application interaction ... // Disconnect events when done appEvents.Unadvise(cookie); console.log('Events disconnected'); } } finally { winax.release(excel); } ``` -------------------------------- ### Accessing COM Properties and Methods Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Retrieve property values or call methods using standard COM access patterns. ```javascript const value = excel.ActiveWorkbook; // Property const cell = ws.Range('A1'); // Method with argument const item = collection(0); // COM index access const byName = fields['FieldName']; // By name const byIndex = fields[0]; // By index ``` -------------------------------- ### new winax.Object(data) Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Object.md Creates a new COM-compatible wrapper for a JavaScript object, allowing it to be passed to COM-based consumers. ```APIDOC ## new winax.Object(data) ### Description Wraps a JavaScript object to expose it to COM-based consumers. This is useful for passing event handlers or configuration objects to COM applications. ### Parameters - **data** (Object) - Required - A JavaScript object containing properties or methods to be exposed to COM. ### Example ```javascript const eventHandler = new winax.Object({ onFinished: function(data) { console.log('Operation finished: ' + data); }, maxRetries: 3, timeout: 5000 }); ``` ``` -------------------------------- ### Interact with ADO Database Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Connect to a database, execute queries, and iterate through recordsets. ```javascript const con = new winax.Object('ADODB.Connection'); con.Open('Provider=MSOLEDBSQL;Server=localhost;Database=db'); const rs = con.Execute('SELECT * FROM table'); rs.MoveFirst(); while (!rs.EOF) { console.log(rs.Fields('name').Value); rs.MoveNext(); } winax.release(rs, con); ``` -------------------------------- ### Discover COM Connection Points Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/ConnectionPointObject.md Inspect a COM object to list its methods, properties, and verify support for connection points. ```javascript const obj = new winax.Object('SomeEventSource'); // List available methods/properties console.log(obj.__methods); console.log(obj.__vars); // Check for connection points if (obj.__ConnectionPoints) { console.log('This object supports events'); } ``` -------------------------------- ### List Floating Point Types Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Displays the supported 32-bit and 64-bit floating point types. ```text 'float' (32-bit), 'double' (64-bit) ``` -------------------------------- ### List Special Types Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Displays special COM types including null, empty, and byref. ```text 'null' (VT_NULL), 'empty' (VT_EMPTY), 'byref' (reference type) ``` -------------------------------- ### Using WScript Global Objects Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Access standard WScript globals like ActiveXObject and WScript.Echo within the node-activex environment. ```javascript // Global objects available var shell = new ActiveXObject('WScript.Shell'); WScript.Echo('Hello'); WScript.Sleep(1000); GetObject('some_moniker'); var e = new Enumerator(collection); ``` -------------------------------- ### Access WScript ScriptFullName Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Retrieves the full path to the currently executing script. ```javascript WScript.ScriptFullName: string ``` ```javascript console.log(WScript.ScriptFullName); // "C:\\scripts\\myscript.js" ``` -------------------------------- ### Manage COM object resources Source: https://github.com/durs/node-activex/blob/master/_autodocs/QUICK_REFERENCE.md Use winax.release to explicitly free COM objects and prevent memory leaks. ```javascript // Release single object winax.release(obj); // Release multiple objects (reverse dependency order) winax.release(fields, recordset, connection); ``` -------------------------------- ### Configure TypeScript compiler options Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Recommended tsconfig.json settings for compatibility with ActiveXObject. ```json { "compilerOptions": { "target": "esnext", "module": "nodenext", "moduleResolution": "nodenext", "lib": ["ESNext"], "skipLibCheck": true, "esModuleInterop": true } } ``` -------------------------------- ### Creating Variant Instances Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Module.md Creates a new Variant instance with a specified COM type. ```javascript Variant(value?: any, type?: VariantType): Variant ``` ```javascript const shortValue = winax.Variant(42, 'short'); const array = winax.Variant([1, 2, 3], 'int'); ``` -------------------------------- ### Handling Property Access Errors Source: https://github.com/durs/node-activex/blob/master/_autodocs/errors.md Demonstrates conditional handling for property access failures. ```javascript try { const obj = new winax.Object('Excel.Application'); const value = obj.NonExistentProperty; } catch(e) { if (e.errno === 0x80020001) { console.error('Property not found on object'); } else if (e.errno === 0x80020005) { console.error('Type mismatch'); } else { console.error('Property access failed:', e.message); } } ``` -------------------------------- ### Implement Graceful Degradation Source: https://github.com/durs/node-activex/blob/master/_autodocs/errors.md Provides a fallback mechanism if an ActiveX object fails to initialize. ```javascript let excel = null; try { excel = new winax.Object('Excel.Application', { activate: true }); } catch(e) { console.warn('Excel not available, using alternative method'); excel = null; } if (excel) { // Use Excel } else { // Use fallback implementation } ``` -------------------------------- ### Connect ActiveX Events Source: https://github.com/durs/node-activex/blob/master/_autodocs/wscript-api.md Define event handler functions and connect them to an ActiveX object using WScript.ConnectObject. ```javascript var excel = new ActiveXObject('Excel.Application'); // Define event handlers function Excel_WorkbookOpen(workbook) { WScript.Echo('Workbook opened: ' + workbook.Name); } function Excel_WorkbookBeforeClose(workbook, cancel) { WScript.Echo('Workbook closing...'); } // Connect handlers WScript.ConnectObject(excel, 'Excel_'); // When events fire, handlers are called automatically excel.Workbooks.Add(); // Triggers Excel_WorkbookOpen // Later disconnect WScript.DisconnectObject(excel); ``` -------------------------------- ### Rebuild for Electron Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Command to rebuild the winax module for specific Electron versions. ```bash npm rebuild winax --runtime=electron --target=X.X.X --arch=x64 --dist-url=https://electronjs.org/headers ``` -------------------------------- ### Manage COM Event Connections Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Uses connection points to advise and unadvise event sinks for COM object events. ```javascript const cp = comObject.__ConnectionPoints; const cookie = cp.Advise(eventSink); // Handle events... cp.Unadvise(cookie); ``` -------------------------------- ### Create COM Wrappers Source: https://github.com/durs/node-activex/blob/master/_autodocs/configuration.md Implements event sinks or custom interfaces by passing a JavaScript object to the constructor. ```javascript const handler = new winax.Object({ onEvent: function(data) { console.log('Event: ' + data); }, getValue: function() { return 42; } }); // Pass to COM application expecting COM object excelApp.OnEventHandler = handler; ``` -------------------------------- ### Handle COM Type Information Source: https://github.com/durs/node-activex/blob/master/_autodocs/INDEX.md Ensures properties are correctly identified using ITypeInfo to prevent misinterpretation as methods. ```javascript // Without type info, EOF might be treated as callable const eof = recordset.EOF; // Correctly treated as property ``` -------------------------------- ### Create Reference Types for COM Methods Source: https://github.com/durs/node-activex/blob/master/_autodocs/api-reference/Variant.md Use 'byref' or 'p' prefixes to create reference types, allowing COM methods to modify parameters in-place. ```javascript const winax = require('winax'); // Create a short by reference const v_short = new winax.Variant(17, 'short'); const v_byref = new winax.Variant(v_short, 'byref'); // Alternative prefix syntax const v_pshort = new winax.Variant(17, 'pshort'); // Pass to COM methods that modify parameters comObject.SomeMethod(v_byref); // Method may modify v_byref's value ```