: Hi! : : Anyone knows how to retrieve information on disk capacity (not only the partition size) using WINAPI functions? : : Thanks! : Check my programs! : Look up [b]GetVolumeInformation[/b] and [b]DeviceIoControl[/b] in MSDN and see if they give what you want
: I checked it out and I found nothing. Do you have any other idea? : : Please help me with this . : Check my programs! : : [green]I'll help you if I can. But first you must help me - what do you WANT to do? What info do you NEED for the partition or disk?[/green]
: I mentioned that already in the first post. The DISK capacity information. : Check my programs! : : [green]You have 4 downloadable programs - which one of them should I check? BTW, have you looked at APIs [b]GetLogicalDrives[/b] and [b]GetLogicalDriveStrings[/b]?[/green]
: You can download all 4 programs . I recommend RPG and numbers. : : I'll look at those functions. Thank you for the tips. : : I'll be back. : Check my programs! : : [green]I still believe that DeviceIoControl is the API for you to use:[code] int main(int argc,char **argv) {
If you try this code with \.PhysicalDriveN and \.C: you will get the same results, provided that N (0+) is the physical drive that holds partition C:. If a 2nd partition is on the same PD, you will still get the same results.
If you want to display or make calculations based on the capacity of the disk, you have to do some LARGE_INTEGER or __int64 arithmetic.[/green]
Comments
:
: Anyone knows how to retrieve information on disk capacity (not only the partition size) using WINAPI functions?
:
: Thanks!
: Check my programs!
:
Look up [b]GetVolumeInformation[/b] and [b]DeviceIoControl[/b] in MSDN and see if they give what you want
Please help me with this
Check my programs!
:
: Please help me with this
: Check my programs!
:
:
[green]I'll help you if I can. But first you must help me - what do you WANT to do? What info do you NEED for the partition or disk?[/green]
Check my programs!
: Check my programs!
:
:
[green]You have 4 downloadable programs - which one of them should I check? BTW, have you looked at APIs [b]GetLogicalDrives[/b] and [b]GetLogicalDriveStrings[/b]?[/green]
I'll look at those functions. Thank you for the tips.
I'll be back.
Check my programs!
:
: I'll look at those functions. Thank you for the tips.
:
: I'll be back.
: Check my programs!
:
:
[green]I still believe that DeviceIoControl is the API for you to use:[code]
int main(int argc,char **argv)
{
BOOL fcc;
HANDLE hFile = INVALID_HANDLE_VALUE;
DISK_GEOMETRY dm;
DWORD dwBytesReturned;
...
hFile = CreateFile
(
argv[1],
GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE,
NULL,
OPEN_EXISTING,
0,
NULL
);
if (hFile == INVALID_HANDLE_VALUE)
{
... // Error handling
}
fcc = DeviceIoControl
(
hFile,
IOCTL_DISK_GET_DRIVE_GEOMETRY,
NULL,
0,
&dm,
sizeof(dm),
&dwBytesReturned,
(LPOVERLAPPED) NULL
)
if (fcc == FALSE)
{
... // Error handling
}
cout << "Geometry for <" << argv[1] << ">:" << endl
<< "Cylinders (low) = " << dm.Cylinders.LowPart << endl
<< "Cylinders (high) = " << dm.Cylinders.HighPart << endl
<< "Media Type = " << dm.MediaType << endl
<< "Tracks per Cylinder = " << dm.TracksPerCylinder << endl
<< "Sectors per Track = " << dm.SectorsPerTrack << endl
<< "Bytes per Sector = " << dm.BytesPerSector
;
...
}
[/code]
If you try this code with \.PhysicalDriveN and \.C: you will get the same results, provided that N (0+) is the physical drive that holds partition C:. If a 2nd partition
If you want to display or make calculations based on the capacity of the disk, you have to do some LARGE_INTEGER or __int64 arithmetic.[/green]