MyLog.cpp
Upload User: weisheen
Upload Date: 2022-07-09
Package Size: 19390k
Code Size: 1k
Development Platform:

Visual C++

  1. // MyLog.cpp: implementation of the MyLog class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "test.h"
  6. #include "MyLog.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif
  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////
  15. MyLog::MyLog()
  16. {
  17. }
  18. MyLog::~MyLog()
  19. {
  20. }
  21. STDMETHODIMP MyLog::WriteLog(BSTR message)
  22. {
  23. CFile f;
  24. CFileException ex;
  25. f.Open("./log.txt",CFile::modeCreate| CFile::modeReadWrite,&ex);
  26. CString str(message);
  27. f.Write(str.GetBuffer(100),str.GetLength());
  28. ::SysFreeString(message);
  29. f.Close();
  30.     return S_OK;
  31. }