Source code of Windows XP (NT5)
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.

153 lines
3.9 KiB

  1. // stdafx.h : include file for standard system include files,
  2. // or project specific include files that are used frequently,
  3. // but are changed infrequently
  4. //
  5. // Copyright (c) 1998-1999 Microsoft Corporation
  6. #if !defined(MSINFO_STDAFX_H)
  7. #define MSINFO_STDAFX_H
  8. #if _MSC_VER >= 1000
  9. #pragma once
  10. #endif // _MSC_VER >= 1000
  11. #ifndef STRICT
  12. #define STRICT
  13. #endif
  14. #include <afxwin.h>
  15. #include <afxdisp.h>
  16. // jps 09/02/97 - This will be 0x0500.
  17. // #define _WIN32_WINNT 0x0400
  18. // jps 09/02/97 - The sample doesn't define this
  19. // #define _ATL_APARTMENT_THREADED
  20. #include <atlbase.h>
  21. #ifndef ATL_NO_NAMESPACE
  22. using namespace ATL;
  23. #endif
  24. // MMC requires unicode DLL's.
  25. #ifndef _UNICODE
  26. #define _UNICODE
  27. #endif
  28. //You may derive a class from CComModule and use it if you want to override
  29. //something, but do not change the name of _Module
  30. extern CComModule _Module;
  31. #include <atlcom.h>
  32. #include "consts.h"
  33. //-----------------------------------------------------------------------------
  34. // This class is used to encapsulate the instrumentation for the snap-in. We
  35. // make this a class so a single instance can be created, and the file closed
  36. // during the destructor.
  37. //-----------------------------------------------------------------------------
  38. class CMSInfoLog
  39. {
  40. public:
  41. enum { BASIC = 0x01, TOOL = 0x02, MENU = 0x04, CATEGORY = 0x08, WMI = 0x10 };
  42. public:
  43. CMSInfoLog();
  44. ~CMSInfoLog();
  45. BOOL IsLogging() { return m_fLoggingEnabled; };
  46. BOOL IsLogging(int iFlag) { return (m_fLoggingEnabled && ((iFlag & m_iLoggingMask) != 0)); };
  47. BOOL WriteLog(int iType, const CString & strMessage, BOOL fContinuation = FALSE);
  48. BOOL WriteLog(int iType, const CString & strFormat, const CString & strReplace1);
  49. private:
  50. BOOL OpenLogFile();
  51. void ReadLoggingStatus();
  52. BOOL WriteLogInternal(const CString & strMessage);
  53. void WriteSpaces(DWORD dwCount);
  54. private:
  55. CFile * m_pLogFile;
  56. CString m_strFilename;
  57. BOOL m_fLoggingEnabled;
  58. int m_iLoggingMask;
  59. DWORD m_dwMaxFileSize;
  60. CString m_strEndMarker;
  61. BOOL m_fTimestamp;
  62. };
  63. extern CMSInfoLog msiLog;
  64. template<class TYPE>
  65. inline void SAFE_RELEASE(TYPE*& pObj)
  66. {
  67. if (pObj != NULL)
  68. {
  69. pObj->Release();
  70. pObj = NULL;
  71. }
  72. else
  73. {
  74. TRACE(_T("Release called on NULL interface ptr\n"));
  75. }
  76. }
  77. #define OLESTR_FROM_CSTRING(cstr) \
  78. (T2OLE(const_cast<LPTSTR>((LPCTSTR)(cstr))))
  79. #define WSTR_FROM_CSTRING(cstr) \
  80. (const_cast<LPWSTR>(T2CW(cstr)))
  81. #ifdef _DEBUG
  82. //#define MSINFO_DEBUG_HACK
  83. #endif // _DEBUG
  84. // Taken from the Example Snap-in.
  85. // Debug instance counter
  86. #ifdef _DEBUG
  87. inline void DbgInstanceRemaining(char * pszClassName, int cInstRem)
  88. {
  89. char buf[100];
  90. wsprintfA(buf, "%s has %d instances left over.", pszClassName, cInstRem);
  91. ::MessageBoxA(NULL, buf, "MSInfo Snapin: Memory Leak!!!", MB_OK);
  92. }
  93. #define DEBUG_DECLARE_INSTANCE_COUNTER(cls) extern int s_cInst_##cls = 0;
  94. #define DEBUG_INCREMENT_INSTANCE_COUNTER(cls) ++(s_cInst_##cls);
  95. #define DEBUG_DECREMENT_INSTANCE_COUNTER(cls) --(s_cInst_##cls);
  96. #define DEBUG_VERIFY_INSTANCE_COUNT(cls) \
  97. extern int s_cInst_##cls; \
  98. if (s_cInst_##cls) DbgInstanceRemaining(#cls, s_cInst_##cls);
  99. #ifdef MSINFO_DEBUG_HACK
  100. extern int g_HackFindMe;
  101. // Temporary fix.
  102. #undef ASSERT
  103. #define ASSERT(f) \
  104. do \
  105. { \
  106. if (!(g_HackFindMe && (f)) && AfxAssertFailedLine(THIS_FILE, __LINE__)) \
  107. g_HackFindMe = 1; \
  108. AfxDebugBreak(); \
  109. } while (0)
  110. #endif // DEBUG_HACK
  111. #else
  112. #define DEBUG_DECLARE_INSTANCE_COUNTER(cls)
  113. #define DEBUG_INCREMENT_INSTANCE_COUNTER(cls)
  114. #define DEBUG_DECREMENT_INSTANCE_COUNTER(cls)
  115. #define DEBUG_VERIFY_INSTANCE_COUNT(cls)
  116. #endif
  117. // Unicode definitions
  118. #ifdef _UNICODE
  119. #define atoi(lpTStr) _wtoi(lpTStr)
  120. #endif
  121. //{{AFX_INSERT_LOCATION}}
  122. // Microsoft Developer Studio will insert additional declarations immediately before the previous line.
  123. #endif // !defined(MSINFO_STDAFX_H)