Getting disk information/Sizes

What is the way/APIs which gives us the size of the fixed_disk? There
can be free/unused space or also some partitions which are not
recognized by WindowsNT, say Linux partitions or so.

Thanks in advance,
Pankaj

Hi!

Try to send CDB with READ_CAPACITY (0x25) to the disk device using SPTI.

Anton Kolomyeytsev

What is the way/APIs which gives us the size of the fixed_disk? There
can be free/unused space or also some partitions which are not
recognized by WindowsNT, say Linux partitions or so.

Thanks in advance,
Pankaj

Got this working using standard IOCTL calls-

static char volumeName = “\\.\PHYSICALDRIVE1”;
HANDLE
volumeHandle;
volumeHandle = CreateFile( volumeName, GENERIC_READ,
FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, 0, 0 );
if( volumeHandle == INVALID_HANDLE_VALUE ) {
printf("\nError opening volume: ");
return FALSE;
}

DISK_GEOMETRY diskGeometry;
BOOL result_new = DeviceIoControl(
volumeHandle,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
0,
&diskGeometry,
sizeof(diskGeometry),
&lpBytesReturned,
(LPOVERLAPPED) NULL
);
//TOTAL_CAPACITY=BYTES_PER_SECTOR*SECTORS_PER_TRACK*TOTAL_HEADS*TOTAL_CYLINDERS
unsigned __int64 size = diskGeometry.Cylinders.QuadPart *
diskGeometry.TracksPerCylinder *
diskGeometry.SectorsPerTrack *
diskGeometry.BytesPerSector;

Thanks anyways,
-Pankaj
Pankaj wrote:

What is the way/APIs which gives us the size of the fixed_disk? There
can be free/unused space or also some partitions which are not
recognized by WindowsNT, say Linux partitions or so.

Thanks in advance,
Pankaj

send IOCTL_DISK_GET_PARTITION_INFORMATION to partition 0
(\.\PhysicalDriveN)

-p

-----Original Message-----
From: Pankaj [mailto:xxxxx@yahoo.com]
Sent: Tuesday, August 20, 2002 1:44 AM
To: NT Developers Interest List
Subject: [ntdev] Getting disk information/Sizes

What is the way/APIs which gives us the size of the fixed_disk? There
can be free/unused space or also some partitions which are not
recognized by WindowsNT, say Linux partitions or so.

Thanks in advance,
Pankaj


You are currently subscribed to ntdev as: xxxxx@microsoft.com To
unsubscribe send a blank email to %%email.unsub%%