问题
Is there a way to use any ActiveX com components with nodejs?
Actually, I would never need this but I'm running nodejs on Windows and trying to send ping requests without forking new processes (no such module exists for Windows).
As some Activex components exist for sending ping requests with raw sockets, maybe I can use them.
An example of how you can create a COM object from JavaScript is:
var rs = new ActiveXObject("ADODB.Recordset");
回答1:
(updated)
You could try to use node-ffi to bind to Win32 and launch a COM/ActiveX component (CoCreateInstance) or access winsock/icmp directly. See https://github.com/rbranson/node-ffi
Or try to ping via WMI, e.g. "select * from win32_pingstatus where Address='...'". See https://npmjs.org/package/wmi
回答2:
There is node-win32ole ( npm install win32ole ).
EDIT: win32ole is no longer actively maintained. You could try winax instead.
回答3:
An ICMP ping module for Node.js now exists:
https://npmjs.org/package/net-ping
回答4:
Years later:
node winax
node win32ole no longer works with up to date node.js versions
来源:https://stackoverflow.com/questions/14356064/using-activex-com-components-with-nodejs-is-it-possible