none
Windows XP - Detect USB device with no device driver installed RRS feed

  • Question

  • First of all, I apologize if I am posting to the wrong forum.  My problem isn't regarding driver development per se, but it is very much device driver & windows related.

    I am working on implementing a driver-repair process for my C# application.

    Early on in the process, I check for the presence of the device through a WMI query:

    public static bool GetDevicePresence(string pattern)
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher(String.Format("SELECT * FROM Win32_PnPEntity where deviceid like '{0}'", pattern));
                ManagementObjectCollection deviceCollection = searcher.Get();
    
                return (deviceCollection.Count > 0);
            }

    ... which I call as follows (XXXX and YYYY in the place of the device's hex values):

    bool rtn = DriverRepair.GetDevicePresence(@"USB\\VID_XXXX&PID_YYYY%");

    In Windows 7, this works every time; regardless of whether device drivers are installed, and device enabled or disabled in Device Manager, the Boolean 'rtn' accurately reflects whether the USB device is plugged in or not.

    In Windows XP however, 'rtn' is accurate as long as the device drivers are installed.  If the drivers are not installed, 'rtn' is assigned a value of FALSE.  This is despite the fact that through Device Manager I can find the driverless device with the correct deviceid.

    I have checked all rows in Win32_PnPEntity, Win32_USBHub, Win32_USBControllerDevice, and Win32_SerialPort (the device uses a USB-SerialPort protocol).  On WinXP with the device driver uninstalled, no additional rows appear upon plugging in the device.  To contrast, Windows XP with the device drivers installed and Windows 7 both gain the additional row in Win32_PnPEntity upon plugging in the device.

    Does anyone have any ideas for alternative ways to detect the presence of a driverless usb device on Windows XP?

    Friday, October 2, 2015 8:57 PM

Answers


  • Does anyone have any ideas for alternative ways to detect the presence of a driverless usb device on Windows XP?

    WMI has changed a lot since WinXP. So for WinXP try something other than WMI - maybe SetupDI. This should work also on Win7 and Win8.

    -- pa

    Friday, October 2, 2015 9:41 PM