<p>I need to programmatically determine out how many sectors, heads, and cylinders are on a physical disk from Windows XP. Does anyone know the API for determining this? Where might Windows expose this information?</p>

[{'answer_id': 50791, 'author': 'Apocalisp', 'author_id': 3434, 'author_profile': 'https://Stackoverflow.com/users/3434', 'pm_score': 1, 'selected': False, 'text': '<p>There\'s a control code you can pass to <a href="http://msdn.microsoft.com/en-us/library/aa365171(VS.85).aspx" rel="nofollow noreferrer">DeviceIoControl</a> to get the physical disk geometry.</p>\n'}, {'answer_id': 50821, 'author': 'ChrisN', 'author_id': 3853, 'author_profile': 'https://Stackoverflow.com/users/3853', 'pm_score': 4, 'selected': True, 'text': '<p>Use <a href="http://msdn.microsoft.com/en-us/library/aa363216%28VS.85%29.aspx" rel="noreferrer">DeviceIoControl</a> with control code <a href="http://msdn.microsoft.com/en-us/library/aa365169%28VS.85%29.aspx" rel="noreferrer">IOCTL_DISK_GET_DRIVE_GEOMETRY</a> or <a href="http://msdn.microsoft.com/en-us/library/aa365171%28VS.85%29.aspx" rel="noreferrer">IOCTL_DISK_GET_DRIVE_GEOMETRY_EX</a>.</p>\n\n<p>There\'s sample code in MSDN to do this <a href="http://msdn.microsoft.com/en-us/library/aa363147%28VS.85%29.aspx" rel="noreferrer">here</a>.</p>\n'}, {'answer_id': 1724560, 'author': 'µBio', 'author_id': 9796, 'author_profile': 'https://Stackoverflow.com/users/9796', 'pm_score': 1, 'selected': False, 'text': '<p>WMI is good at this too, I\'ve used it with great success.  </p>\n\n<pre><code>using( ManagementClass driveClass = new ManagementClass( "Win32_DiskDrive" ) )\n{\n    using( ManagementObjectCollection physicalDrives = driveClass.GetInstances( ) )\n    {\n        foreach( ManagementObject drive in physicalDrives )\n        {\n            string cylinders = ( string )drive["TotalCylinders"];\n            // ... etc ...\n            drive.Dispose( );\n        }\n    }\n}\n</code></pre>\n\n<p>For a list of additional drive properties you can use, check out <a href="http://msdn.microsoft.com/en-us/library/aa394132(VS.85).aspx" rel="nofollow noreferrer">this page</a></p>\n'}]
['https://Stackoverflow.com/questions/50762', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/2171/']