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.

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