All pastes #1520 Raw Edit

Segosa

public cpp v1 · immutable
#1520 ·published 2004-10-17 05:36 UTC
rendered paste body
	// what happens is that even though szFName 	// is the filename of a 1.9MB file, when I	// read the contents, it seems to only have read 3 bytes.	HANDLE hFile = CreateFile(szFName,FILE_WRITE_DATA|FILE_READ_DATA,								   FILE_SHARE_READ|FILE_SHARE_WRITE,								   NULL,								   OPEN_EXISTING,								   FILE_ATTRIBUTE_NORMAL,								   NULL);		if (hFile == INVALID_HANDLE_VALUE) {		MessageBox(NULL,CANTOPEN,APPNAME,MB_OK);		return;	}	DWORD nRead=0;		int nSize = GetFileSize(hFile,NULL); // this sets properly to 1949696		char *szRead = new char[nSize+1]; // string to hold it all	if (!ReadFile(hFile,szRead,nSize,&nRead,NULL))		display_error(); // never gets called	MessageBox(NULL,szRead,NULL,0); // seems to only display three characters		char *tmp = new char[256];	itoa(strlen(szRead),tmp,10);	MessageBox(NULL,tmp,NULL,MB_OK); // strlen(szRead) is 3		itoa(nSize,tmp,10);	MessageBox(NULL,tmp,NULL,MB_OK); // nSize is the size, 1949696		itoa(nRead,tmp,10);	MessageBox(NULL,tmp,NULL,MB_OK); // nRead is the size too, 1949696	// so it should have read the whole thing, but it doesn't	// seem to ..