hi all
I am trying to figure out what does GetDriveType() API return for USB CDROM.
I have found that it returns DRIVE_FIXED for USB hard disk,but for USB pen drive it returns DRIVE_REMOVABLE.
Now, my doubt is, does it return DRIVE_CDROM or DRIVE_REMOVABLE for USB CDROM. I can’t test it on my own bcos I don’t have a USB CDROM.
Can u please enlighten me abt this thing. I am pasting the code that I use for this purpose. I try to check it as soon as the USB device is plugged in by using WM_DEVICECHANGE iun wndproc function in a win32 application.
//function for finding the drive letter for the USB device(disk/pendrive/cdrom)
//added.
char FirstDriveFromMask(unsigned long unitmask)
{
char i;
for (i = 0; i < 26; ++i)
{
if (unitmask & 0x1)
break;
unitmask = unitmask >> 1;
}
return (i + ‘A’);
}
//
// FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
//
// PURPOSE: Processes messages for the main window.
//
LRESULT CALLBACK WndProc(HWND hWnd, UINT message, WPARAM wParam, LPARAM lParam)
{
switch (message)
{
case WM_DEVICECHANGE:
{
PDEV_BROADCAST_HDR lpdb = (PDEV_BROADCAST_HDR)lParam;
if(wParam == DBT_DEVICEARRIVAL)
{
if(lpdb->dbch_devicetype == DBT_DEVTYP_VOLUME)
{
PDEV_BROADCAST_VOLUME lpdv =
(PDEV_BROADCAST_VOLUME) lpdb;
{
char szMsg[50];
memset(szMsg, ‘\0’, 50);
sprintf (szMsg, “%c:\”, FirstDriveFromMask(lpdv ->dbcv_unitmask));
UINT x = GetDriveType(szMsg);
if(x == DRIVE_REMOVABLE)
MessageBox(NULL,“Removable”, “”, MB_OK);
else if(x == DRIVE_CDROM)
MessageBox(NULL,“CDROM”, “”, MB_OK);
}
}
}
DefWindowProc(hWnd, message, wParam, lParam);
break;
}
default:
return DefWindowProc(hWnd, message, wParam, lParam);
}
}
Thanks & regards
Pankaj
Yahoo! India Answers: Share what you know. Learn something new Click here
Send free SMS to your Friends on Mobile from your Yahoo! Messenger Download now