• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 198
  • Last Modified:

Detecting actual physical drive size

Is there a routine I can use to detect the actual physical drive size (including Non-formatted space!) of a drive?

I seem to recall the Win API report the formatted space but I need a routine/function that reports the actual physical size the drive was built for.
  • 2
1 Solution
You need to use the API function DeviceIoControl and the IOCTL_DISK_GET_DRIVE_GEOMETRY command.
rascalAuthor Commented:
I assume this requires I write a device driver? Is there a non-device driver way to perform the same thing by any chance?
rascalAuthor Commented:
I looked up IOCTL_DISK_GET_DRIVE_GEOMETRY and found an example in the MSDN and it appears I do not need a device driver (phew!).

I neglected to mention I need a solution that works on Win9X platforms as well as NT and Win2K and IOCTL_DISK_GET_DRIVE_GEOMETRY is NT/Win2K specific.

Can you recommend a Win9x solution as well by any chance?
In addition to what jhance already suggested, 'IOCTL_DISK_GET_DRIVE_LAYOUT' might be an option, too...
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now