Monitor Connections to My Computer's USB Ports Using LabVIEW

Updated Aug 17, 2023

Reported In

Software

  • LabVIEW

Operating System

  • Windows

Issue Details

I want to develop an application that monitors the USB connections. This will help me filter the USB devices that are useful for it from the rest.

Is there a way to monitor the USB ports programmatically in LabVIEW.

Solution

It does not exist a LabVIEW's native function to accomplish this. Below, you will find some ideas:

  1. You can use the Call Library Function Node to call the kernell32.dll. This DLL contains a function called "GetLogicalDriveStringsA" that will return the different USB devices connected to the computer. Refer to the Related Links for more information.
  2. This example explores the way of using the Window's Registers to obtain the information about the USB devices connected.
  3. LabVIEW does have a native way to monitor joystick, keyboard or mouse. Check the Related Links sections for more information.
  4. If you know how to acquire this information from the command prompt, you could use the System Exec VI .
  5. pnputils in CMD can list some additional information about the USB devices:
    1. pnputil /enum-devices /connected /class "USB" > C:\Users\USER\Desktop\usb.txt
    2. This will create a usb.txt on the desktop (substitute USER for your current username

Additional Information

You can find the kernell32.dll at C:\Windows\System32\ 
There is no option to display or monitor the ports where the USB devices are connected.