views:

54

answers:

0

i get notification when a new device is plugged or unplugged from the system using WM_DEVICECHANGE

i can able to get vendor id,product id and corresponding drive letter , when a device is inserted one by one.

please refer the code below

switch( pHdr->dbch_devicetype )
{
  case DBT_DEVTYP_DEVICEINTERFACE:
        pDevInf = ( PDEV_BROADCAST_DEVICEINTERFACE )pHdr;
    updateDevice( pDevInf, wParam , pDevVolume );
    break;
  case DBT_DEVTYP_VOLUME:
        pDevVolume = ( PDEV_BROADCAST_VOLUME )pHdr;
        myDriveLetter = pDevVolume->dbcv_unitmask;
}

In the DBT_DEVTYP_DEVICEINTERFACE case i get the vendor id and product id information

i have updateDevice() function to pass the vendor id and product id parameters

In the DBT_DEVTYP_VOLUME case i get the drive letter information for a plugged device

there is no problem when i plug device one by one

But when insert two device at the same time, i miss one of the drive letter

if i insert two device means pDevVolume->dbcv_unitmask gives multiple bits set

but what my problem is when i plug a device it calls the DBT_DEVTYP_DEVICEINTERFACE case first.

in that case i have updateDevice() function to pass the vendor id and product id parameters.

the DBT_DEVTYP_VOLUME case called secondly the variable "myDriveLetter" stores the pDevVolume->dbcv_unitmask.

if i simultaneously plug two devices means one bit mask value will be vanished.how can i solve this ..

can anybody suggest me for my above problem