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.

201 lines
5.2 KiB

  1. // This is a part of the Microsoft Management Console.
  2. // Copyright 1995 - 1997 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. #undef _MSC_EXTENSIONS
  12. // define this symbol to insert another level of User,Company,Virtual
  13. // nodes whenever one of the nodes is expanded
  14. // #define RECURSIVE_NODE_EXPANSION
  15. #include <afxwin.h>
  16. #include <afxext.h> // MFC extensions
  17. #include <afxdisp.h>
  18. #include "afxtempl.h"
  19. //#include <shellapi.h>
  20. #include <atlbase.h>
  21. using namespace ATL;
  22. //You may derive a class from CComModule and use it if you want to override
  23. //something, but do not change the name of _Module
  24. extern CComModule _Module;
  25. #include <atlcom.h>
  26. //#include "afxtempl.h"
  27. #pragma comment(lib, "mmc")
  28. #include <mmc.h>
  29. const long UNINITIALIZED = -1;
  30. // Constants used in samples
  31. const int NUM_FOLDERS = 4;
  32. const int NUM_NAMES = 4;
  33. const int NUM_COMPANY = 6;
  34. const int NUM_VIRTUAL_ITEMS = 100000;
  35. const int MAX_ITEM_NAME = 64;
  36. // Sample folder types
  37. enum FOLDER_TYPES
  38. {
  39. STATIC = 0x8000,
  40. COMPANY = 0x8001,
  41. USER = 0x8002,
  42. VIRTUAL = 0x8003,
  43. EXT_COMPANY = 0x8004,
  44. EXT_USER = 0x8005,
  45. EXT_VIRTUAL = 0x8006,
  46. NONE = 0xFFFF
  47. };
  48. /////////////////////////////////////////////////////////////////////////////
  49. // Helper functions
  50. template<class TYPE>
  51. inline void SAFE_RELEASE(TYPE*& pObj)
  52. {
  53. if (pObj != NULL)
  54. {
  55. pObj->Release();
  56. pObj = NULL;
  57. }
  58. else
  59. {
  60. TRACE(_T("Release called on NULL interface ptr\n"));
  61. }
  62. }
  63. extern const CLSID CLSID_Snapin; // In-Proc server GUID
  64. extern const CLSID CLSID_Extension; // In-Proc server GUID
  65. extern const CLSID CLSID_About;
  66. ///////////////////////////////////////////////////////////////////////////////
  67. //
  68. // OBJECT TYPES
  69. //
  70. //
  71. // OBJECT TYPE for Scope Nodes.
  72. //
  73. // Static NodeType GUID in numeric & string formats.
  74. extern const GUID cNodeTypeStatic;
  75. extern const wchar_t* cszNodeTypeStatic;
  76. // Company Data NodeType GUID in numeric & string formats.
  77. extern const GUID cNodeTypeCompany;
  78. extern const wchar_t* cszNodeTypeCompany;
  79. // User Data NodeType GUID in numeric & string formats.
  80. extern const GUID cNodeTypeUser;
  81. extern const wchar_t* cszNodeTypeUser;
  82. // Extension Company Data NodeType GUID in numeric & string formats.
  83. extern const GUID cNodeTypeExtCompany;
  84. extern const wchar_t* cszNodeTypeExtCompany;
  85. // Extension User Data NodeType GUID in numeric & string formats.
  86. extern const GUID cNodeTypeExtUser;
  87. extern const wchar_t* cszNodeTypeExtUser;
  88. // Extension Virtual NodeType GUID in numeric & string formats.
  89. extern const GUID cNodeTypeVirtual;
  90. extern const wchar_t* cszNodeTypeVirtual;
  91. // Dynamicaly created objects.
  92. extern const GUID cNodeTypeDynamic;
  93. extern const wchar_t* cszNodeTypeDynamic;
  94. //
  95. // OBJECT TYPE for result items.
  96. //
  97. // Result items object type GUID in numeric & string formats.
  98. extern const GUID cObjectTypeResultItem;
  99. extern const wchar_t* cszObjectTypeResultItem;
  100. //
  101. //
  102. //////////////////////////////////////////////////////////////////////////////
  103. // New Clipboard format that has the Type and Cookie
  104. extern const wchar_t* SNAPIN_INTERNAL;
  105. // Published context information for extensions to extend
  106. extern const wchar_t* SNAPIN_WORKSTATION;
  107. struct INTERNAL
  108. {
  109. INTERNAL()
  110. {
  111. m_type = CCT_UNINITIALIZED;
  112. m_cookie = -1;
  113. ZeroMemory(&m_clsid, sizeof(CLSID));
  114. };
  115. ~INTERNAL() {}
  116. DATA_OBJECT_TYPES m_type; // What context is the data object.
  117. MMC_COOKIE m_cookie; // What object the cookie represents
  118. CString m_string; //
  119. CLSID m_clsid; // Class ID of who created this data object
  120. INTERNAL & operator=(const INTERNAL& rhs)
  121. {
  122. if (&rhs == this)
  123. return *this;
  124. // Deep copy the information
  125. m_type = rhs.m_type;
  126. m_cookie = rhs.m_cookie;
  127. m_string = rhs.m_string;
  128. memcpy(&m_clsid, &rhs.m_clsid, sizeof(CLSID));
  129. return *this;
  130. }
  131. BOOL operator==(const INTERNAL& rhs)
  132. {
  133. return rhs.m_string == m_string;
  134. }
  135. };
  136. // Debug instance counter
  137. #ifdef _DEBUG
  138. inline void DbgInstanceRemaining(char * pszClassName, int cInstRem)
  139. {
  140. char buf[100];
  141. wsprintfA(buf, "%s has %d instances left over.", pszClassName, cInstRem);
  142. ::MessageBoxA(NULL, buf, "SAMPLE: Memory Leak!!!", MB_OK);
  143. }
  144. #define DEBUG_DECLARE_INSTANCE_COUNTER(cls) extern int s_cInst_##cls = 0;
  145. #define DEBUG_INCREMENT_INSTANCE_COUNTER(cls) ++(s_cInst_##cls);
  146. #define DEBUG_DECREMENT_INSTANCE_COUNTER(cls) --(s_cInst_##cls);
  147. #define DEBUG_VERIFY_INSTANCE_COUNT(cls) \
  148. extern int s_cInst_##cls; \
  149. if (s_cInst_##cls) DbgInstanceRemaining(#cls, s_cInst_##cls);
  150. #else
  151. #define DEBUG_DECLARE_INSTANCE_COUNTER(cls)
  152. #define DEBUG_INCREMENT_INSTANCE_COUNTER(cls)
  153. #define DEBUG_DECREMENT_INSTANCE_COUNTER(cls)
  154. #define DEBUG_VERIFY_INSTANCE_COUNT(cls)
  155. #endif