Solved

IOCTL_DISK_GET_DRIVE_GEOMETRY fails after change of removable disk

Posted on 2003-11-18
3
695 Views
Last Modified: 2013-12-03
I am writing a simple floppy disk dump program and try to determine the geometry of the inserted disk so that I get the correct numbers for tracks, sectors per track and so on.
However, if I insert a (formatted) floppy disk and call DeviceIoControl with IOCTL_DISK_GET_DRIVE_GEOMETRY, I only get an error back (1110) which means that the disk could have changed. I know that it changed, just how do I initialize it properly before checking the geometry?
One workaround is to instantiate a CFileFind object and search for any file on the floppy drive, but this is only a poor solution. Can anybody please point me to something smarter for this case?
I also noticed there seems to be a problem to read oversized disks (like 1.72 megabytes instead of 1.44), any smart solution for this? Operating systems are Windows 2000 and Windows XP. In Windows 9x, everything seems to work fine...

0
Comment
Question by:engelmann_media
  • 2
3 Comments
 
LVL 86

Accepted Solution

by:
jkr earned 125 total points
ID: 9773880
>> I know that it changed, just how do I initialize it properly before checking the geometry?

Close the device handle and re-open it again.
0
 
LVL 2

Author Comment

by:engelmann_media
ID: 9778273
Unfortunately, this doesn't work. I am sorry I forgot to mention this, my fault :)
I found this solution a day ago or so and tried it, but the sequence CreateFile(...), CloseHandle(...), CreateFile(...) does not change the behaviour. I still get FALSE returned and GetLastError states 1110. Everything works fine if I use the CFileFind workaround, but I don't feel comfortable with this :)

Any other ideas?
0
 
LVL 2

Author Comment

by:engelmann_media
ID: 9781784
Okay, You were right, I'll award you the points :) The trick is to close and reopen the device right after an error. Open, close, reopen does not work in a prophylactic way ;)
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

In this article, I will show how to use the Ribbon IDs Tool Window to assign the built-in Office icons to a ribbon button.  This tool will help us to find the OfficeImageId that corresponds to our desired built-in Office icon. The tool is part of…
As more and more people are shifting to the latest .Net frameworks, the windows presentation framework is gaining importance by the day. Many people are now turning to WPF controls to provide a rich user experience. I have been using WPF controls fo…
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

746 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

10 Experts available now in Live!

Get 1:1 Help Now