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.

130 lines
3.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1998 **/
  4. /**********************************************************************/
  5. /*
  6. extract.h
  7. FILE HISTORY:
  8. */
  9. #ifndef _EXTRACT_H
  10. #define _EXTRACT_H
  11. #if _MSC_VER >= 1000 // VC 5.0 or later
  12. #pragma once
  13. #endif
  14. #ifndef __mmc_h__
  15. #include <mmc.h>
  16. #endif
  17. struct INTERNAL
  18. {
  19. INTERNAL()
  20. {
  21. m_type = CCT_UNINITIALIZED;
  22. m_cookie = -1;
  23. m_index = -1;
  24. ZeroMemory(&m_clsid, sizeof(CLSID));
  25. };
  26. ~INTERNAL() {}
  27. DATA_OBJECT_TYPES m_type; // What context is the data object.
  28. MMC_COOKIE m_cookie; // What object the cookie represents
  29. CString m_string; //
  30. CLSID m_clsid; // Class ID of who created this data object
  31. int m_index; // index of the item in the virtual listbox
  32. BOOL HasVirtualIndex() { return m_index != -1; }
  33. int GetVirtualIndex() { return m_index; }
  34. INTERNAL & operator=(const INTERNAL& rhs)
  35. {
  36. if (&rhs == this)
  37. return *this;
  38. m_type = rhs.m_type;
  39. m_cookie = rhs.m_cookie;
  40. m_string = rhs.m_string;
  41. memcpy(&m_clsid, &rhs.m_clsid, sizeof(CLSID));
  42. return *this;
  43. }
  44. BOOL operator==(const INTERNAL& rhs)
  45. {
  46. return rhs.m_string == m_string;
  47. }
  48. };
  49. // SPINTERNAL
  50. DeclareSmartPointer(SPINTERNAL, INTERNAL, if (m_p) GlobalFree((void *) m_p) )
  51. //
  52. // Extracts a data type from a data object
  53. //
  54. template <class TYPE>
  55. TYPE* Extract(LPDATAOBJECT lpDataObject, CLIPFORMAT cf, int nSize)
  56. {
  57. ASSERT(lpDataObject != NULL);
  58. TYPE* p = NULL;
  59. STGMEDIUM stgmedium = { TYMED_HGLOBAL, NULL };
  60. FORMATETC formatetc = { cf, NULL,
  61. DVASPECT_CONTENT, -1, TYMED_HGLOBAL
  62. };
  63. int len;
  64. // Allocate memory for the stream
  65. if (nSize == -1)
  66. {
  67. len = sizeof(TYPE);
  68. }
  69. else
  70. {
  71. //int len = (cf == CDataObject::m_cfWorkstation) ?
  72. // ((MAX_COMPUTERNAME_LENGTH+1) * sizeof(TYPE)) : sizeof(TYPE);
  73. len = nSize;
  74. }
  75. stgmedium.hGlobal = GlobalAlloc(GMEM_SHARE, len);
  76. // Get the workstation name from the data object
  77. do
  78. {
  79. if (stgmedium.hGlobal == NULL)
  80. break;
  81. if (FAILED(lpDataObject->GetDataHere(&formatetc, &stgmedium)))
  82. break;
  83. p = reinterpret_cast<TYPE*>(stgmedium.hGlobal);
  84. if (p == NULL)
  85. break;
  86. } while (FALSE);
  87. return p;
  88. }
  89. struct INTERNAL;
  90. TFSCORE_API(INTERNAL*) ExtractInternalFormat(LPDATAOBJECT lpDataObject);
  91. TFSCORE_API(GUID *) ExtractNodeType(LPDATAOBJECT lpDataObject);
  92. TFSCORE_API(CLSID *) ExtractClassID(LPDATAOBJECT lpDataObject);
  93. TFSCORE_API(WCHAR *) ExtractComputerName(LPDATAOBJECT lpDataObject);
  94. TFSCORE_API(BOOL) IsMMCMultiSelectDataObject(LPDATAOBJECT lpDataObject);
  95. #endif