Windows programming

Moderators: None (Apply to moderate this forum)
Number of threads: 3670
Number of posts: 9122

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
win32 file I/O programming problem Posted by SamBx on 29 Jun 2010 at 7:41 AM
I have a weird win32 File I/O issue on a lab data collection/presentation system. When the operators told me
they were having sporadic issues like missing data, changes not taking, etc I suspected a file-writing error of some sort.
So I made up a little test
thread that every 5 minutes simply appends an "I am well" line to a text file as follows...

//============== called every 5 minutes from background thread
int XAppendTimeLine() //for debug purposes only
{ int bfsz,i,j=-99,k=-99,w=-99,r=-99,sfp=-99; HANDLE hfile; char buff[2000],err[200];
hfile=CreateFile("Marktime.txt", GENERIC_READ|GENERIC_WRITE,0,NULL, OPEN_ALWAYS,
FILE_ATTRIBUTE_NORMAL,NULL);
if (hfile==HANDLERR) {r=-1; goto finn;}
sfp= SetFilePointer(hfile,0,NULL,FILE_END);
sprintf(buff,"I am fine at %s\n\r",strCurrDateTime(); bfsz=strlen(buff);
w=WriteFile(hfile,buff,bfsz,&k,NULL);
if (w==FALSE) r=-9999; else r=k;
j=CloseHandle(hfile); if (j==0) r=-8888;
finn:
sprintf(err,"<r=%d; han=%d sfp=%d w=%d c=%d>",r,hfile,sfp,w,j);
Mywmdebug(err);
return r;
}
//==============


This little routine runs correctly for a few hours after app startup,
but after that no more lines get appended
to the file. However if I look
at my debug log output everything continues to appear as if its working; no error returns show up.
Strangely what I
see in the log streams is that sfp (the returned result of the SetFilePointer call)
continues to grow as if the data was properly written.

At this point Im clueless as to what is happening or what to try next. Any Ideas??
Report
Re: win32 file I/O programming problem Posted by anthrax11 on 29 Jun 2010 at 3:44 PM
It's a long shot, but maybe you're looking at the data using the old Windows 9x notepad, which only supports files up to 64kB..



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.