how to read entire 1.44 mb of a floppy


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
 
Ad

Advertisements

O

Olof Lagerkvist

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, ...);
 
E

erajaysharma

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::blush:ut | 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
 
O

Olof Lagerkvist

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).
 
Ad

Advertisements

E

erajaysharma

<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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top