PDA

View Full Version : Not solved



newb
28th June 2010, 07:27
Hi ..

I am using Qt with win32..

I can able to get notified on new device insertion and removal using DBT_DEVTYP_DEVICEINTERFACE

if ( DBT_DEVICEARRIVAL == wParam || DBT_DEVICEREMOVECOMPLETE == wParam )
{
PDEV_BROADCAST_HDR pHdr = ( PDEV_BROADCAST_HDR )lParam;

PDEV_BROADCAST_DEVICEINTERFACE pDevInf;

PDEV_BROADCAST_VOLUME pDevVolume = reinterpret_cast<PDEV_BROADCAST_VOLUME>(lParam);

switch( pHdr->dbch_devicetype )
{
case DBT_DEVTYP_DEVICEINTERFACE:
pDevInf = ( PDEV_BROADCAST_DEVICEINTERFACE )pHdr;
updateDevice( pDevInf, wParam);
break;
}
}
anybody please tell me how can i get the drive information ( G:/ ) for the above notication

newb
28th June 2010, 11:00
really i have been trying for the past 3 days..

can anybody help me

Vit Stepanek
28th June 2010, 11:07
I'm afraid you're not at the right forum. The code you've provided is from win api. Try some win32 related forum, some like this one: http://social.msdn.microsoft.com/Forums/en-US/windowssdk/threads

LaOnze2000
1st July 2010, 23:21
Maybe you have the solution by now.
I use something like this to get the drive letter for CD insert and removal.
I think it might work for any device.

static char FirstDriveFromMask (ULONG unitmask)
{
char i;

for (i = 0; i < 26; ++i)
{
if (unitmask & 0x1)
break;
unitmask = unitmask >> 1;
}

return (i + 'A');

}

In your code ...
PDEV_BROADCAST_HDR pHdr = ( PDEV_BROADCAST_HDR )lParam;
PDEV_BROADCAST_VOLUME pvol= (PDEV_BROADCAST_VOLUME) pHdr;
char Drive_Letter = FirstDriveFromMask(pvol->dbcv_unitmask);

Good luck