I need to find the vendor Id, Product Id of the usb drive connected to the system, through java code. Any suggestions...
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
I have never interfaced with USB in Java before, but have a look at JSR-80 (javax.usb) API. IBM DeveloperWorks have a tutorial (which can be useful).
回答2:
If you need windows only use WMI. I do not think that cross-platform pure java solution exists at all.
You have several ways to connect to WMI. Check out Jawin, Jintegra, Jinterop. All these libraries support WMI. You can also create WMI script using VBScript or JScript and run as an external command line tool from Java using cscript
command.