如何检测使用Node.js连接的USB设备 [英] How to Detect USB device connected using Node.js

查看:742
本文介绍了如何检测使用Node.js连接的USB设备的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述





我是Node.js的新手。我想检测是否有任何USB / Mass存储设备连接到系统。



因为我们在C#中有类似的东西需要



Hi,

I am newbie to Node.js. I would like to detect if any USB / Mass storage device is connected to the system.

As we have something in C# to do like

// Add USB plugged event watching
            watcherAttach = new ManagementEventWatcher();
            watcherAttach.EventArrived += watcherAttach_EventArrived;
            watcherAttach.Query = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 2");
            watcherAttach.Start();

            // Add USB unplugged event watching
            watcherDetach = new ManagementEventWatcher();
            watcherDetach.EventArrived += watcherDetach_EventArrived;
            watcherDetach.Query = new WqlEventQuery("SELECT * FROM Win32_DeviceChangeEvent WHERE EventType = 3");
            watcherDetach.Start();





请建议我们如何在Node.js中执行类似C#的操作。 />


先谢谢。

Aryan



Please suggest how we can do something similar of C# in Node.js.

Thanks in Advance.
Aryan

推荐答案

这些链接可能会有所帮助< br $>


https://github.com/schakko/ node-usb [ ^ ]



https://github.com/voodootikigod/node-serialport [ ^ ]
These links may be helpful

https://github.com/schakko/node-usb[^]

https://github.com/voodootikigod/node-serialport[^]


这篇关于如何检测使用Node.js连接的USB设备的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆