In my c++ application I'm rying to read iso file asynchronous by createfile
- with overlapped flag and after it - readfile
.
however when I try this code on a simple file (txt file for example) it works. but when I run this code on iso file - it fails.
I saw in MSDN that compressed file can only read by readfile sync calls. does iso files is in this category?
if yes - do you have other suggestion how to read iso files async?
this is my code:
int _tmain(int argc, _TCHAR* argv[])
{
HANDLE hFile;
DWORD NumberOfBytesRead = 0, dw;
BYTE *buf = (BYTE*)malloc(BUF_SIZE*sizeof(BYTE));
OVERLAPPED overlapped;
overlapped.Offset = overlapped.OffsetHigh = 0;
memset(buf, 0, 1024);
overlapped.hEvent = CreateEvent(NULL, true, false, NULL);
if(NULL == overlapped.hEvent)
printf("error");
hFile = CreateFile("xxx.iso",
GENERIC_READ,
FILE_SHARE_READ,
NULL,
OPEN_EXISTING,
FILE_FLAG_OVERLAPPED | FILE_ATTRIBUTE_NORMAL | FILE_FLAG_NO_BUFFERING ,
NULL);
if (hFile == INVALID_HANDLE_VALUE)
printf("invalid hfile\n");
int i;
i= ReadFile(hFile,
buf,
BUF_SIZE,
&NumberOfBytesRead,
&overlapped);
if( GetLastError() == ERROR_IO_PENDING)
{
dw = WaitForSingleObject(overlapped.hEvent, INFINITE);
if(dw == WAIT_OBJECT_0)
if (GetOverlappedResult(hFile,&overlapped,&NumberOfBytesRead, TRUE) != 0)
{
if (NumberOfBytesRead != 0)
{
printf("!!!\n");
}
}
}
thanks