Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

145 lines
2.9 KiB

  1. // stdafx.cpp : source file that includes just the standard includes
  2. // stdafx.pch will be the pre-compiled header
  3. // stdafx.obj will contain the pre-compiled type information
  4. #include "stdafx.h"
  5. #ifdef _ATL_STATIC_REGISTRY
  6. #include <statreg.h>
  7. #include <statreg.cpp>
  8. #endif
  9. #include <atlimpl.cpp>
  10. #define COUNT_OF(a) (sizeof(a) / sizeof(a[0]))
  11. //---------------------------------------------------------------------------
  12. // CAdmtModule Class
  13. //---------------------------------------------------------------------------
  14. CAdmtModule::CAdmtModule()
  15. {
  16. }
  17. CAdmtModule::~CAdmtModule()
  18. {
  19. }
  20. // OpenLog Method
  21. bool CAdmtModule::OpenLog()
  22. {
  23. // CloseLog(); // error class doesn't reset file pointer to NULL when closing file
  24. return m_Error.LogOpen(GetMigrationLogPath(), 0, 0, true) ? true : false;
  25. }
  26. // CloseLog Method
  27. void CAdmtModule::CloseLog()
  28. {
  29. m_Error.LogClose();
  30. }
  31. // Log Method
  32. void __cdecl CAdmtModule::Log(UINT uLevel, UINT uId, ...)
  33. {
  34. _TCHAR szFormat[512];
  35. _TCHAR szMessage[1024];
  36. if (LoadString(GetResourceInstance(), uId, szFormat, 512))
  37. {
  38. va_list args;
  39. va_start(args, uId);
  40. _vsntprintf(szMessage, COUNT_OF(szMessage), szFormat, args);
  41. va_end(args);
  42. szMessage[1023] = _T('\0');
  43. }
  44. else
  45. {
  46. szMessage[0] = _T('\0');
  47. }
  48. m_Error.MsgProcess(uLevel | uId, szMessage);
  49. }
  50. // Log Method
  51. void __cdecl CAdmtModule::Log(UINT uLevel, UINT uId, _com_error& ce)
  52. {
  53. try
  54. {
  55. _bstr_t strMessage;
  56. _TCHAR szMessage[512];
  57. if (LoadString(GetResourceInstance(), uId, szMessage, 512) == FALSE)
  58. {
  59. szMessage[0] = _T('\0');
  60. }
  61. strMessage = szMessage;
  62. _bstr_t strDescription = ce.Description();
  63. if (strDescription.length())
  64. {
  65. strMessage += _T(" ") + strDescription;
  66. }
  67. _TCHAR szError[32];
  68. _stprintf(szError, _T(" (0x%08lX)"), ce.Error());
  69. strMessage += szError;
  70. m_Error.MsgProcess(uLevel | uId, strMessage);
  71. }
  72. catch (...)
  73. {
  74. }
  75. }
  76. // Log Method
  77. void __cdecl CAdmtModule::Log(LPCTSTR pszFormat, ...)
  78. {
  79. _TCHAR szMessage[1024];
  80. if (pszFormat)
  81. {
  82. va_list args;
  83. va_start(args, pszFormat);
  84. _vsntprintf(szMessage, COUNT_OF(szMessage), pszFormat, args);
  85. va_end(args);
  86. szMessage[1023] = _T('\0');
  87. }
  88. else
  89. {
  90. szMessage[0] = _T('\0');
  91. }
  92. m_Error.MsgProcess(0, szMessage);
  93. }
  94. StringLoader gString;
  95. //#import <ActiveDs.tlb> no_namespace implementation_only exclude("_LARGE_INTEGER","_SYSTEMTIME")
  96. #import <DBMgr.tlb> no_namespace implementation_only
  97. #import <MigDrvr.tlb> no_namespace implementation_only
  98. #import <VarSet.tlb> no_namespace rename("property", "aproperty") implementation_only
  99. #import <WorkObj.tlb> no_namespace implementation_only
  100. #import <MsPwdMig.tlb> no_namespace implementation_only
  101. #import <adsprop.tlb> no_namespace implementation_only
  102. #import "Internal.tlb" no_namespace implementation_only