Click here to Skip to main content
15,905,028 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
AnswerRe: Private/internal classes - opinions? Pin
Dennis Gourjii30-Jan-07 12:00
Dennis Gourjii30-Jan-07 12:00 
AnswerRe: Private/internal classes - opinions? Pin
charlieg1-Feb-07 8:40
charlieg1-Feb-07 8:40 
QuestionVisual C++ ... Visual Basic ... Visual C# [modified] Pin
Khoramdin30-Jan-07 7:18
Khoramdin30-Jan-07 7:18 
AnswerRe: Visual C++ ... Visual Basic ... Visual C# Pin
Hamid_RT30-Jan-07 7:28
Hamid_RT30-Jan-07 7:28 
AnswerRe: Visual C++ ... Visual Basic ... Visual C# Pin
Christian Graus30-Jan-07 9:20
protectorChristian Graus30-Jan-07 9:20 
QuestionRe: Visual C++ ... Visual Basic ... Visual C# Pin
Khoramdin31-Jan-07 12:52
Khoramdin31-Jan-07 12:52 
AnswerRe: Visual C++ ... Visual Basic ... Visual C# Pin
Christian Graus31-Jan-07 21:28
protectorChristian Graus31-Jan-07 21:28 
QuestionCreateFile Problem Pin
TurboNext30-Jan-07 6:27
TurboNext30-Jan-07 6:27 
I am creating a log file and writing to it in a function called WriteToLog. I am creating the file using CreateFile and writing to it using WriteFile. The problem is the filepointer is not moving and always I have only 1 sentence in my logfile, its just overwriting the file and even though I write lot of sentences into my logfile. I just see the last sentence that I wrote to it.

Any help greatly appreciated.

Thanks
Sai.


VOID WriteToLog(LPCTSTR lpszFormat, ...)
{
CString csT1,csT2;
va_list args;
BOOL bRet=FALSE;
HANDLE hFile=NULL;
SYSTEMTIME stTime;
DWORD dwT1=0;

va_start(args, lpszFormat);
csT1.FormatV(lpszFormat,args);
va_end(args);

CSingleLock oLockcopyCounter(&g_oMessageOutputSection);


oLockcopyCounter.Lock();
GetLocalTime(&stTime);
csT2.Format("%s[0x%x] %02d/%02d/%04d %02d:%02d:%02d.%03d: %s", "\r\n",GetCurrentThreadId(),stTime.wMonth, stTime.wDay,
stTime.wYear, stTime.wHour, stTime.wMinute, stTime.wSecond, stTime.wMilliseconds,(PCHAR)(LPCTSTR)csT1);
hFile=CreateFile(g_szLogFileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
if(hFile!=INVALID_HANDLE_VALUE)
{
if(GetFileSize(hFile,NULL)> (5*1024*1024))
{
CloseHandle(hFile);DeleteFile(g_szLogFileName);
ReportAsEvent(EVENTLOG_INFORMATION_TYPE,0,"Deleting File %s since it croseed 5 MB Limit",g_szLogFileName);
hFile=CreateFile(g_szLogFileName,GENERIC_WRITE,FILE_SHARE_WRITE,NULL,OPEN_ALWAYS,FILE_ATTRIBUTE_NORMAL,NULL);
}
if(hFile!=INVALID_HANDLE_VALUE)
{
WriteFile(hFile,csT2,csT2.GetLength(),&dwT1,NULL);
WriteFile(hFile,csT2,csT2.GetLength(),&dwT1,NULL);
CloseHandle(hFile);
}
else
ReportAsEvent(EVENTLOG_ERROR_TYPE,0,"Creating File %s FAILED. Error %d",g_szLogFileName,GetLastError());
}
oLockcopyCounter.Unlock();
}
AnswerRe: CreateFile Problem Pin
David Crow30-Jan-07 6:31
David Crow30-Jan-07 6:31 
AnswerRe: CreateFile Problem Pin
Mark Salsbery30-Jan-07 6:36
Mark Salsbery30-Jan-07 6:36 
GeneralRe: CreateFile Problem Pin
TurboNext30-Jan-07 6:58
TurboNext30-Jan-07 6:58 
QuestionMaking strong passwords readeable Pin
Kharfax30-Jan-07 4:14
Kharfax30-Jan-07 4:14 
AnswerRe: Making strong passwords readeable Pin
Maximilien30-Jan-07 6:23
Maximilien30-Jan-07 6:23 
GeneralRe: Making strong passwords readeable Pin
Kharfax30-Jan-07 6:38
Kharfax30-Jan-07 6:38 
AnswerRe: Making strong passwords readeable Pin
markkuk30-Jan-07 23:00
markkuk30-Jan-07 23:00 
GeneralRe: Making strong passwords readeable Pin
Kharfax31-Jan-07 0:56
Kharfax31-Jan-07 0:56 
QuestionVista issues Pin
Waldermort30-Jan-07 4:04
Waldermort30-Jan-07 4:04 
AnswerRe: Vista issues Pin
Michael Dunn30-Jan-07 7:27
sitebuilderMichael Dunn30-Jan-07 7:27 
GeneralRe: Vista issues Pin
Waldermort30-Jan-07 16:55
Waldermort30-Jan-07 16:55 
AnswerRe: Vista issues Pin
slipnit30-Jan-07 7:32
slipnit30-Jan-07 7:32 
GeneralRe: Vista issues Pin
James R. Twine30-Jan-07 7:36
James R. Twine30-Jan-07 7:36 
GeneralRe: Vista issues Pin
slipnit30-Jan-07 7:56
slipnit30-Jan-07 7:56 
AnswerRe: Vista issues Pin
James R. Twine30-Jan-07 7:37
James R. Twine30-Jan-07 7:37 
GeneralRe: Vista issues Pin
Waldermort30-Jan-07 16:57
Waldermort30-Jan-07 16:57 
AnswerRe: Vista issues Pin
Ravi Bhavnani30-Jan-07 10:58
professionalRavi Bhavnani30-Jan-07 10:58 

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.