Solved

Detecting actual physical drive size

Posted on 2001-06-29
4
184 Views
Last Modified: 2008-03-10
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.
0
Comment
Question by:rascal
  • 2
4 Comments
 
LVL 32

Accepted Solution

by:
jhance earned 100 total points
ID: 6239042
You need to use the API function DeviceIoControl and the IOCTL_DISK_GET_DRIVE_GEOMETRY command.
0
 
LVL 1

Author Comment

by:rascal
ID: 6239052
I assume this requires I write a device driver? Is there a non-device driver way to perform the same thing by any chance?
0
 
LVL 1

Author Comment

by:rascal
ID: 6239068
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?
0
 
LVL 86

Expert Comment

by:jkr
ID: 6239087
In addition to what jhance already suggested, 'IOCTL_DISK_GET_DRIVE_LAYOUT' might be an option, too...
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…

929 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now