PORTS Forum

Ports and Interfaces => USB => Topic started by: lcpoon on February 09, 2014, 09:14:14 am

Title: WinUSB WndProc()
Post by: lcpoon on February 09, 2014, 09:14:14 am
I am using WinUSB VB codes to display list of the devices that uses the same inf driver and then perform different task on each device.

The problem was if I connected and disconnected other USB devices (mouse, keyboard and etc), the OnDeviceChange() is executed.

I would like to have OnDeviceChange() executed if and only if any WinUSB device (same inf driver) is connected/ disconnected. Previously, I am thinking of to add in codes to count the number of WinUSB devices to do so. Please advise if there is better approach to implement this, thanks.

        Protected Overrides Sub WndProc(ByRef m As Message)
            Try
                If m.Msg = DeviceManagement.WM_DEVICECHANGE Then
                    OnDeviceChange()
                End If
                MyBase.WndProc(m)
            Catch ex As Exception
                Throw
            End Try
        End Sub
Title: Re: WinUSB WndProc()
Post by: Jan Axelson on February 09, 2014, 09:59:39 am
Why not capture all changes and search for your device by path name?

My latest WinUSB examples use WMI instead of OnDeviceChange:

http://www.janaxelson.com/winusb.htm