CreateFile() keeps returning INVALID_HANDLE_VALUE.
Posted on 1998-06-10
I am writing a disk copier in MS Visual C++ V. 4 which copies entire disks sector by sector and run Windows '95. I am using CreateFile() to get a handle to a floppy disk drive, then using ReadFile() to read the contents of the entire disk into memory. However, when I try to get a handle to drive A, I keep getting an INVALID_HANDLE_VALUE. I tried it with drive C (my HD) and got the same result as well. I enclose my code fragment below. Do you know why it's not working and if so, what can I do to get it working?
pFile = CreateFile("\\.\A:",
GENERIC_READ | GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE,
// pFile now contains INVALID_HANDLE_VALUE, rather than a handle to drive A!!
Thanks for your time