Click here to Skip to main content
15,921,716 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Why does creating a static window from a console app cause havok? Pin
David Crow19-Jul-05 7:32
David Crow19-Jul-05 7:32 
GeneralRe: Why does creating a static window from a console app cause havok? Pin
Trollslayer19-Jul-05 6:11
mentorTrollslayer19-Jul-05 6:11 
GeneralRe: Why does creating a static window from a console app cause havok? Pin
IGx8919-Jul-05 7:05
IGx8919-Jul-05 7:05 
GeneralRe: Why does creating a static window from a console app cause havok? Pin
Trollslayer19-Jul-05 7:35
mentorTrollslayer19-Jul-05 7:35 
GeneralRe: Why does creating a static window from a console app cause havok? Pin
David Crow19-Jul-05 7:49
David Crow19-Jul-05 7:49 
GeneralRe: Why does creating a static window from a console app cause havok? Pin
James Brown19-Jul-05 7:56
James Brown19-Jul-05 7:56 
GeneralRe: Why does creating a static window from a console app cause havok? Pin
IGx8919-Jul-05 9:34
IGx8919-Jul-05 9:34 
Generalfread crash Pin
sfeldi19-Jul-05 4:40
sfeldi19-Jul-05 4:40 
Hey,

maybe someone could help with this one... and yes I did look in the archives for help but failed to find any...

so, I am trying to read a file. It gets opened OK, the size is checked OK... then I call fread for 1 byte and it blows up...

the thing is also that these files are supposed to be cached. At the beginning only the directory structure is cached and the file names/info, but not the file contents itself, until the file is actually accessed, or so it seems. The cache is disk based, and if it helps at all, it is created by PointSoft Jukebox manager. It is just a software that drives a big DVD jukebox where the data that I need is read from....

is there any method or anything that would overcome this? I have also tryed unbuffered and buffered reads...

...or maybe I am just doing something stupid that I fail to see?...

<br />
FILE* file = fopen( m_oblFileName, "rt" );<br />
<br />
if( file==NULL ) <br />
{<br />
	// handle this<br />
	// .....<br />
	return false;<br />
}<br />
<br />
DWORD dwFileSize=GetFileLength(m_oblFileName);<br />
<br />
if (dwFileSize<1)<br />
{<br />
	// hnadle this<br />
	// ......<br />
	return false;<br />
}<br />
<br />
char chTmp;<br />
if (0>=fread(&chTmp,1,1,file)){<br />
	// blabla....<br />
	return false;<br />
}<br />
else<br />
	fseek(file,0,SEEK_SET);<br />
<br />
CString strLine;<br />
while(ReadLine(strLine, file)>0)<br />
// .....<br />


the other two lame functions that I used, but dont seem to be relevant because they do not crash

<br />
long GetFileLength( LPCTSTR szFileName )<br />
{<br />
	long length=0;<br />
	int handle = _open( szFileName, _O_RDONLY );<br />
	<br />
	if( handle!=-1 ) <br />
	{<br />
		length = _filelength(handle);<br />
		_close(handle);<br />
	}<br />
	return length;<br />
}<br />
<br />
int ReadLine(CString &strLine, FILE *pFile)<br />
{<br />
	char mmm[2]={0};<br />
	CString strTemp;<br />
<br />
	while((mmm[0]!=10))<br />
	{<br />
		if (fread( mmm, 1, 1,pFile)!=1)<br />
		{<br />
			if (feof(pFile)&&(strTemp.GetLength()>0))<br />
				break;<br />
			<br />
			fclose(pFile);<br />
			return -1;<br />
		}<br />
<br />
		mmm[1]=0;<br />
		strTemp+=mmm;<br />
	}<br />
	<br />
	strLine=strTemp;<br />
	<br />
	strLine.TrimLeft("\n\t\r");<br />
	strLine.TrimRight("\n\t\r");<br />
	<br />
	glb_Log.DebugLog2(TRUE,"ReadingLine = '%s'",strLine);<br />
<br />
	return strLine.GetLength();<br />
}<br />

GeneralRe: fread crash Pin
David Crow19-Jul-05 5:28
David Crow19-Jul-05 5:28 
GeneralRe: fread crash Pin
Chris Losinger19-Jul-05 6:48
professionalChris Losinger19-Jul-05 6:48 
GeneralRe: fread crash Pin
David Crow19-Jul-05 7:17
David Crow19-Jul-05 7:17 
GeneralRe: fread crash Pin
Chris Losinger19-Jul-05 7:30
professionalChris Losinger19-Jul-05 7:30 
GeneralRe: fread crash Pin
David Crow19-Jul-05 7:40
David Crow19-Jul-05 7:40 
GeneralRe: fread crash Pin
Chris Losinger19-Jul-05 8:03
professionalChris Losinger19-Jul-05 8:03 
GeneralRe: fread crash Pin
David Crow19-Jul-05 8:52
David Crow19-Jul-05 8:52 
GeneralRe: fread crash Pin
Chris Losinger19-Jul-05 9:27
professionalChris Losinger19-Jul-05 9:27 
GeneralRe: fread crash Pin
sfeldi19-Jul-05 20:39
sfeldi19-Jul-05 20:39 
GeneralRe: fread crash Pin
sfeldi19-Jul-05 21:09
sfeldi19-Jul-05 21:09 
GeneralRe: fread crash Pin
Chris Losinger20-Jul-05 1:11
professionalChris Losinger20-Jul-05 1:11 
GeneralRe: fread crash Pin
sfeldi19-Jul-05 20:38
sfeldi19-Jul-05 20:38 
QuestionTextOut being clipped in Windows 2000? Pin
MacWarrior19-Jul-05 3:10
MacWarrior19-Jul-05 3:10 
AnswerRe: TextOut being clipped in Windows 2000? Pin
David Crow19-Jul-05 3:21
David Crow19-Jul-05 3:21 
GeneralReading REG_SZ from Win registry Pin
rudoq3219-Jul-05 3:09
rudoq3219-Jul-05 3:09 
GeneralRe: Reading REG_SZ from Win registry Pin
David Crow19-Jul-05 3:19
David Crow19-Jul-05 3:19 
GeneralRe: Reading REG_SZ from Win registry Pin
Blake Miller19-Jul-05 5:50
Blake Miller19-Jul-05 5:50 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.