I have some c code with me which detects the usb cable removal and insertion.
I found one structure DEV_BROADCAST_DEVICEINTERFACE
which is having
You need to cast a DEV_BROADCAST_HEADER*
to a DEV_BROADCAST_DEVICEINTERFACE*
. You are allowed to do so if and only if dbch_devicetype==DBT_DEVTYP_DEVICEINTERFACE
.
You getDEV_BROADCAST_HEADER*
as the LPARAM
of WM_DEVICECHANGE
.
To do something useful with dbcc_name,
you have to pass it to SetupDiOpenDeviceInterface()
. This will give you a SP_DEVICE_INTERFACE_DATA
with one SP_DEVINFO_DATA
. You can then call functions like SetupDiGetDeviceRegistryProperty
to learn more about the device.
Please notice the CodeSet. If it is Unicode. The data is \\0......