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:
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