how to read entire 1.44 mb of a floppy

  • Thread starter Thread starter erajaysharma
  • Start date Start date
E

erajaysharma

Hi,

Can any one please tell me how can i read entire 1.44 mb of data from
a floppy starting from sector 0.

Thanks,

Ajay
 
Hi,

Can any one please tell me how can i read entire 1.44 mb of data from
a floppy starting from sector 0.


Basically,

HANDLE h = CreateFile("\\\\.\\A:", GENERIC_READ, ..., OPEN_EXISTING, ...);
ReadFile(h, buffer, ...);
 
Basically,

HANDLE h = CreateFile("\\\\.\\A:", GENERIC_READ, ..., OPEN_EXISTING, ...);
ReadFile(h, buffer, ...);

Hi Olof,

I am using following code but it reads only upto 38 K...i want to
write a program which can read entire 1.44 mb, put it into a file and
returns after reading 1.44 mb...

#define SIZE 512
int main()
{
DWORD dwBytesRead;
unsigned char data[SIZE];
HANDLE hFloppy;
hFloppy = CreateFile(
"\\\\.\\A:",
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
0,
NULL);

if(hFloppy == INVALID_HANDLE_VALUE)
printf("CreateFile failed\n");

fstream outFile;
outFile.open("image.bin", ios::out | ios::binary);
if(outFile.fail())//check for any problems
{
printf("outFile not opened\n");
return 0;
}

while(1)
{
if(!ReadFile(hFloppy, &data, SIZE,&dwBytesRead, NULL))
{
printf("Read failed.\n");
break;
}

if(!dwBytesRead)
break;

outFile.write(data,SIZE);
}
outFile.close();
}

Thanks,
Ajay
 
I am using following code but it reads only upto 38 K...i want to
write a program which can read entire 1.44 mb, put it into a file and
returns after reading 1.44 mb...

<chop>
I can't say I see any obvious problem with that code though I did not
compile and test it. Maybe you could add some debug printouts reporting
the read complete size you get from ReadFile() and also what
GetLastError() returns in case ReadFile() fails (returns FALSE).
 
<chop>
I can't say I see any obvious problem with that code though I did not
compile and test it. Maybe you could add some debug printouts reporting
thereadcomplete size you get from ReadFile() and also what
GetLastError() returns in case ReadFile() fails (returns FALSE).

Thanks Olof,

but i am able to read entire floppy now...i dont know the
reason....floppy it self is a very unreliable medium...
may be thats the reason

Ajay
 
Back
Top