Hi all, forgive me if this is a newbie problem but I can't figure it out. What I'm doing is opening a file, then trying to read it in. I get an error when I try to do the read.
"An unknown error occurred while accessing an unnamed file."
I've traced the problem to this function
From what I've read about this is it checks to make sure there's enough memory? Here's my code anyway, you'll see what I'm doing. Maybe some of you gurus have seen this before. Thanks.
AfxMessageBox("Didn't open file");
//create memory for teh file header
//read the header into memory
AfxMessageBox("Couldn't read the file");
//check to make sure the file is a valid bitmap
if(bmpFileHead.bfType == 0x4d42)
AfxMessageBox("Is a bmp");
//need the length of the file for further processing
DWORD fileLength = dibFile.GetLength();
//take the size of the header away from the length, we already have the header in memory
DWORD size = fileLength - sizeof(BITMAPFILEHEADER);
//create a pointer to the bitmap data as a chunk of memory
BYTE* pDib = (BYTE*)::GlobalAlloc(GMEM_MOVEABLE, size);
int x = ::GetLastError();
SIZE_T y = GlobalSize(pDib);
get last error returns 0, so the memory is being allocated, and GlobalSize is returning the same number as size. that means the memory is definately allocated right??
//read the data into the array
[green]//this next line is causing the error
//I followed the program into the CFile::Read function
//where AfxIsValidAddress is checked. [/green]
dibFile.Read((void*)pDib, size); [/red]