reading disk sector in WinNT

I was wondering how I can read a sector of a hard disk. I was hoping I could do it with CreateFile('\\.\PhysicalDrive0',...) and then read the drive with ReadFile. But that doesn't work. CreateFile creates a handle ok, but ReadFile keeps me giving error 87 (wrong parameter). Anyone any ideas?

Kind regards,

Djafken
LVL 1
DjafkenAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NickRepinCommented:
INFO: Direct Drive Access Under Win32
http://support.microsoft.com/support/kb/articles/Q100/0/27.asp 

There is a sample at
http://support.microsoft.com/support/kb/articles/Q138/4/34.asp 

This sample is about CD-ROM, but it is fully applicable to floppy

Floppy Sample: Accessing a Floppy Disk
http://msdn.microsoft.com/library/devprods/vs6/visualc/vcsample/vcsmpfloppysampleaccessingfloppydisk.htm
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NickRepinCommented:
Hard, floppy, CD-ROM - no difference.
0
NickRepinCommented:
When performing direct disk I/O, you must seek, read, and write in multiples of sector sizes of the device and on sector boundaries. It seems that you don't, that's why you get this error.
0
DjafkenAuthor Commented:
Thanks, the problem was indeed the sector size, just like you mentioned.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.