long myLong;
ReadFile(hFile, &myLong, sizeof(long), NumBytesRead, NULL);
LastError = GetLastError();
LastError = 87 which is
The parameter is incorrect. ERROR_INVALID_PARAMETER
I don''t understand, I''ve been using ReadFile() ever since. I tested all the functions before it and no error. What''s wrong?
ReadFile() Error
Unless NumBytesRead is a pointer, I think you need to pass it &NumBytesRead as the 4th parameter is an LPDWORD. (This is just from what I just read out of the MSDN.. might be completely wrong).
I declared it as
If it wasn't I would get a compile error:
error C2664: 'ReadFile' : cannot convert parameter 4 from 'unsigned long' to 'unsigned long *'
so....not that.
Hmmm, what seems to be the problem is that previous I put the codes in a function in a .dll ... but when I implimented the code locally, nothing is wrong. Hmmm something wrong with the function call?
Edited by - vbisme on November 30, 2000 12:15:39 AM
LPDWORD NumBytesRead;
If it wasn't I would get a compile error:
error C2664: 'ReadFile' : cannot convert parameter 4 from 'unsigned long' to 'unsigned long *'
so....not that.
Hmmm, what seems to be the problem is that previous I put the codes in a function in a .dll ... but when I implimented the code locally, nothing is wrong. Hmmm something wrong with the function call?
Edited by - vbisme on November 30, 2000 12:15:39 AM
//in DLLclass GFXFileInfo{public: long NumberOfFiles; long TotaDataSize;};LINKDLL GFXFileInfo LoadGFXFile(LPCTSTR FileName, PBYTE & rGFXFile){HANDLE hFile; //file handleGFXFileInfo GFXfileinfo;LPDWORD NumBytesRead = NULL; //indicationsDWORD FileSize, FileSizeHigh, LastError;///Open the file for readinghFile = CreateFile(FileName, GENERIC_READ, 0, NULL, OPEN_EXISTING, FILE_FLAG_SEQUENTIAL_SCAN, NULL);//ReadFile(hFile, &GFXfileinfo, sizeof(GFXFileInfo), NumBytesRead, NULL);GFXfileinfo.TotaDataSize = GetFileSize(hFile, &FileSizeHigh);///Get the number of files///Allocate memory for pointer to GFX FilerGFXFile = (PBYTE)malloc(GFXfileinfo.TotaDataSize);///Read the opened file into pointerReadFile(hFile, rGFXFile, FileSize, NumBytesRead, NULL);return(GFXfileinfo);}//Main function:PBYTE pGFXFileContainer;GFXFileInfo FileInfo;FileInfo = LoadGFXFile("filename.gfx", pGFXFileContainer);
The fourth parameter to ReadFile cannot be NULL. The easiest way to fix that would be to redeclare NumBytesRead as a LONG and instead pass it''s address to ReadFile.
I have used ReadFile myself, but I was just wondering, is it faster to use a compiler''s built-in file access?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement
Recommended Tutorials
Advertisement