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.

125 lines
3.5 KiB

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