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.

128 lines
3.6 KiB

  1. //+--------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. // Copyright (C) Microsoft Corporation, 1994 - 1998.
  5. //
  6. // File: stdafx.h
  7. //
  8. // Contents: include file for standard system include files, or project
  9. // specific include files that are used frequently, but are
  10. // changed infrequently
  11. //
  12. // History: 03-14-1998 stevebl Commented
  13. //
  14. //---------------------------------------------------------------------------
  15. #include <afxwin.h>
  16. #include <afxdisp.h>
  17. #include <atlbase.h>
  18. //You may derive a class from CComModule and use it if you want to override
  19. //something, but do not change the name of _Module
  20. extern CComModule _Module;
  21. #ifdef DBG
  22. //
  23. // ATL's implementation of Release always returns 0 unless _DEBUG is
  24. // defined. The debug version of OLE.DLL asserts Release() != 0 in certain
  25. // circumstances. I don't want to define _DEBUG because it brings in a
  26. // whole lot of baggage from MMC that I don't want to deal with, but I do
  27. // want to avoid this assertion in OLE, so on debug builds, I'll go ahead
  28. // and define _DEBUG for the appropriate ATL header file but I'll undefine
  29. // it again right afterward. This is a little flakey but it is relatively
  30. // safe and it achieves the desired goal.
  31. //
  32. // - SteveBl
  33. //
  34. #define _DEBUG
  35. #endif
  36. #include <atlcom.h>
  37. #ifdef DBG
  38. #undef _DEBUG
  39. #endif
  40. #pragma comment(lib, "mmc")
  41. #include <mmc.h>
  42. #include "afxtempl.h"
  43. const long UNINITIALIZED = -1;
  44. // Sample folder types
  45. enum FOLDER_TYPES
  46. {
  47. STATIC = 0x8000,
  48. };
  49. /////////////////////////////////////////////////////////////////////////////
  50. // Helper functions
  51. template<class TYPE>
  52. inline void SAFE_RELEASE(TYPE*& pObj)
  53. {
  54. if (pObj != NULL)
  55. {
  56. pObj->Release();
  57. pObj = NULL;
  58. }
  59. else
  60. {
  61. TRACE(_T("Release called on NULL interface ptr\n"));
  62. }
  63. }
  64. extern const CLSID CLSID_Snapin; // In-Proc server GUID
  65. extern const GUID cNodeType; // Main NodeType GUID on numeric format
  66. extern const wchar_t* cszNodeType; // Main NodeType GUID on string format
  67. // New Clipboard format that has the Type and Cookie
  68. extern const wchar_t* SNAPIN_INTERNAL;
  69. struct INTERNAL
  70. {
  71. INTERNAL() { m_type = CCT_UNINITIALIZED; m_cookie = -1;};
  72. ~INTERNAL() {}
  73. DATA_OBJECT_TYPES m_type; // What context is the data object.
  74. MMC_COOKIE m_cookie; // What object the cookie represents
  75. CString m_string;
  76. INTERNAL & operator=(const INTERNAL& rhs)
  77. {
  78. if (&rhs == this)
  79. return *this;
  80. m_type = rhs.m_type;
  81. m_cookie = rhs.m_cookie;
  82. m_string = rhs.m_string;
  83. return *this;
  84. }
  85. BOOL operator==(const INTERNAL& rhs)
  86. {
  87. return rhs.m_string == m_string;
  88. }
  89. };
  90. // Debug instance counter
  91. #ifdef _DEBUG
  92. inline void DbgInstanceRemaining(char * pszClassName, int cInstRem)
  93. {
  94. char buf[100];
  95. wsprintfA(buf, "%s has %d instances left over.", pszClassName, cInstRem);
  96. ::MessageBoxA(NULL, buf, "Memory Leak!!!", MB_OK);
  97. }
  98. #define DEBUG_DECLARE_INSTANCE_COUNTER(cls) extern int s_cInst_##cls = 0;
  99. #define DEBUG_INCREMENT_INSTANCE_COUNTER(cls) ++(s_cInst_##cls);
  100. #define DEBUG_DECREMENT_INSTANCE_COUNTER(cls) --(s_cInst_##cls);
  101. #define DEBUG_VERIFY_INSTANCE_COUNT(cls) \
  102. extern int s_cInst_##cls; \
  103. if (s_cInst_##cls) DbgInstanceRemaining(#cls, s_cInst_##cls);
  104. #else
  105. #define DEBUG_DECLARE_INSTANCE_COUNTER(cls)
  106. #define DEBUG_INCREMENT_INSTANCE_COUNTER(cls)
  107. #define DEBUG_DECREMENT_INSTANCE_COUNTER(cls)
  108. #define DEBUG_VERIFY_INSTANCE_COUNT(cls)
  109. #endif