HANDLE hDisk;
DISK_GEOMETRY diskGeometry;
DWORD dwBytes;
for (int i = 0; i < 255; i ++)
{
wchar_t str[18];
swprintf (str, L"\\\\.\\PhysicalDrive%d", i);
hDisk = CreateFile(str, MAXIMUM_ALLOWED, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL);
if (hDisk != INVALID_HANDLE_VALUE)
{
DeviceIoControl(hDisk, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &diskGeometry, sizeof (DISK_GEOMETRY), &dwBytes, NULL);
// Only proceed if disk is a removable media
if (diskGeometry.MediaType == RemovableMedia)
{
// Display disk information ....
// TODO: Display USB reader information
}
}
}
HANDLE hDisk;
DISK_GEOMETRY diskGeometry;
DWORD dwBytes;
for (int i = 0; i < 255; i ++)
{
wchar_t str[18];
swprintf (str, L"\\\\.\\PhysicalDrive%d", i);
hDisk = CreateFile(str, MAXIMUM_ALLOWED, FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL, OPEN_EXISTING, 0, NULL);
if (hDisk != INVALID_HANDLE_VALUE)
{
DeviceIoControl(hDisk, IOCTL_DISK_GET_DRIVE_GEOMETRY, NULL, 0, &diskGeometry, sizeof (DISK_GEOMETRY), &dwBytes, NULL);
// Only proceed if disk is a removable media
if (diskGeometry.MediaType == RemovableMedia)
{
// Display disk information ....
// TODO: Display USB reader information
}
}
}
To copy to clipboard, switch view to plain text mode
Bookmarks