Click here to Skip to main content
16,005,178 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralOutput Box In VC++ Pin
Caoimh31-Jan-04 6:11
Caoimh31-Jan-04 6:11 
GeneralRe: Output Box In VC++ Pin
Mukkie31-Jan-04 8:16
Mukkie31-Jan-04 8:16 
GeneralAttaching Dialogs to Single Document Applications Pin
Caoimh31-Jan-04 5:59
Caoimh31-Jan-04 5:59 
GeneralRe: Attaching Dialogs to Single Document Applications Pin
Mukkie31-Jan-04 8:11
Mukkie31-Jan-04 8:11 
GeneralRegions, randomizing images Pin
Worthi31-Jan-04 5:01
Worthi31-Jan-04 5:01 
GeneralNotification on Welcome Screen Pin
MrAndrew31-Jan-04 4:49
MrAndrew31-Jan-04 4:49 
GeneralRe: Notification on Welcome Screen Pin
Michael Dunn31-Jan-04 7:52
sitebuilderMichael Dunn31-Jan-04 7:52 
GeneralStrange file corruption Pin
Artem Moroz31-Jan-04 4:11
Artem Moroz31-Jan-04 4:11 
I have a class that represents a log file.

This class has two functions and a member variable
CFile m_file

First is StartLog conains code
m_file.Open(.....);

Second StopLog contanis code
m_file.Close();

And also there is a function AddEvent like this:

m_file.Write(.....);
m_file.Flush();

I call StartLog when my program starts, and StopLog when it exits. AddEvent is called several times while program runs;

It works fine mostly, but there is a problem:
File gets corrupted (it contains junk) when the program gets terminated incorrectly. For example when somebody has rebooted computer or terminates it via task manger. (Close() is not get called in this case)

Should I reopen and close file every time I need to write to it to ensure safety of the data???

Confused | :confused:
GeneralRe: Strange file corruption Pin
valikac31-Jan-04 5:29
valikac31-Jan-04 5:29 
GeneralRe: Strange file corruption Pin
Artem Moroz31-Jan-04 5:50
Artem Moroz31-Jan-04 5:50 
GeneralRe: Strange file corruption Pin
valikac31-Jan-04 12:06
valikac31-Jan-04 12:06 
GeneralRe: Strange file corruption Pin
Terry O'Nolley31-Jan-04 16:15
Terry O'Nolley31-Jan-04 16:15 
QuestionControlling Mouse Positions in MFC? Pin
Dev57831-Jan-04 3:45
Dev57831-Jan-04 3:45 
AnswerRe: Controlling Mouse Positions in MFC? Pin
User 665831-Jan-04 4:24
User 665831-Jan-04 4:24 
GeneralRe: Controlling Mouse Positions in MFC? Pin
Dev57831-Jan-04 4:39
Dev57831-Jan-04 4:39 
Generalerror C2955...error in template resolution Pin
Member 49228431-Jan-04 3:16
Member 49228431-Jan-04 3:16 
GeneralRe: error C2955...error in template resolution Pin
Joaquín M López Muñoz31-Jan-04 6:14
Joaquín M López Muñoz31-Jan-04 6:14 
GeneralCListCtrl Scrollbar Pin
Konrad Windszus31-Jan-04 2:46
Konrad Windszus31-Jan-04 2:46 
GeneralRe: CListCtrl Scrollbar Pin
JussiL4-Feb-04 20:59
JussiL4-Feb-04 20:59 
GeneralLINK : fatal error LNK1181: --> How to overcome this Pin
Anonymous31-Jan-04 0:50
Anonymous31-Jan-04 0:50 
GeneralRe: LINK : fatal error LNK1181: --> How to overcome this Pin
Konrad Windszus31-Jan-04 2:49
Konrad Windszus31-Jan-04 2:49 
Questionhow to enable/disable on mouse click? Pin
coda_x31-Jan-04 0:45
coda_x31-Jan-04 0:45 
AnswerRe: how to enable/disable on mouse click? Pin
amit sebiz31-Jan-04 0:56
amit sebiz31-Jan-04 0:56 
Questionhow to hook & override api functions!!!!!!!!!!!!!!! Pin
vocongminh31-Jan-04 0:43
sussvocongminh31-Jan-04 0:43 
AnswerRe: how to hook & override api functions!!!!!!!!!!!!!!! Pin
User 665831-Jan-04 1:07
User 665831-Jan-04 1:07 

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.