2010-08-11 6 views

Répondre

1

Vous pouvez essayer GetLogicalDriveStrings pour obtenir les lettres de lecteur, puis utiliser GetDriveType pour voir, si un lecteur est amovible ou non. Ensuite, vous pouvez obtenir plus d'informations sur l'appareil comme ceci (l'exemple est pour cd-rom mais devrait vous montrer l'idée):

//handle to the drive to be examined 
HANDLE hDevice = CreateFile(TEXT("\\\\.\\G:"), //Drive to open 
GENERIC_READ|GENERIC_WRITE, //Access to the drive 
FILE_SHARE_READ|FILE_SHARE_WRITE, //Share mode 
NULL, //Security 
OPEN_EXISTING,0, // no file attributes 
NULL); 

if (hDevice == INVALID_HANDLE_VALUE) return 0; 

CDROM_TOC val; // table of contents for a generic CDROM 
DWORD nBytesReturned; 

BOOL bResult= DeviceIoControl(
hDevice, 
IOCTL_CDROM_READ_TOC,//operation to perform 
&val, sizeof(val),//no input buffer 
&val, sizeof(val),//output buffer 
&nBytesReturned,//#bytes returned 
(LPOVERLAPPED) NULL);//synchronous I/O 

CloseHandle(hDevice); 
Questions connexes