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.

100 lines
3.0 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. extract.cpp
  7. FILE HISTORY:
  8. */
  9. #include "stdafx.h"
  10. #include "extract.h"
  11. #ifdef _DEBUG
  12. #define new DEBUG_NEW
  13. #undef THIS_FILE
  14. static char THIS_FILE[] = __FILE__;
  15. #endif
  16. // Internal private format
  17. extern const wchar_t* SNAPIN_INTERNAL; // = L"SNAPIN_INTERNAL";
  18. // Generic MMC computer name format (also used by Computer Management snapin)
  19. const wchar_t* MMC_SNAPIN_MACHINE_NAME = L"MMC_SNAPIN_MACHINE_NAME";
  20. static unsigned int s_cfNodeType = RegisterClipboardFormat(CCF_NODETYPE);
  21. static unsigned int s_cfCoClass = RegisterClipboardFormat(CCF_SNAPIN_CLASSID);
  22. static unsigned int s_cfInternal = RegisterClipboardFormat(SNAPIN_INTERNAL);
  23. static unsigned int s_cfComputerName = RegisterClipboardFormat(MMC_SNAPIN_MACHINE_NAME);
  24. /*!--------------------------------------------------------------------------
  25. IsMMCMultiSelectDataObject
  26. returns whether or not this dataobject is multiselect
  27. This only works for MMC supplied dataobjects. Here is a list
  28. of notifications and what we can expect for DataObjects:
  29. MMC-MS-DO is an MMC supplied DO
  30. SI_MS_DO is a snapin supplied DO
  31. MMCN_BTN_CLICK MMC-MS-DO
  32. MMCN_CONTEXTMENU MMC-MS-DO
  33. MMCN_CUTORMOVE CUTORMOVE_DO
  34. MMCN_DELETE SI_MS_DO
  35. MMCN_QUERY_PASTE MMC-MS-DO
  36. MMCN_PASTE SI_MS_DO
  37. MMCN_SELECT SI_MS_DO
  38. Author: EricDav
  39. ---------------------------------------------------------------------------*/
  40. BOOL
  41. IsMMCMultiSelectDataObject
  42. (
  43. IDataObject* pDataObject
  44. )
  45. {
  46. HRESULT hr;
  47. BOOL bMultiSelect = FALSE;
  48. COM_PROTECT_TRY
  49. {
  50. if (pDataObject == NULL)
  51. return FALSE;
  52. static UINT s_cf = 0;
  53. if (s_cf == 0)
  54. {
  55. USES_CONVERSION;
  56. s_cf = RegisterClipboardFormat(CCF_MMC_MULTISELECT_DATAOBJECT);
  57. }
  58. FORMATETC fmt = {(CLIPFORMAT) s_cf, NULL, DVASPECT_CONTENT, -1, TYMED_HGLOBAL};
  59. bMultiSelect = (pDataObject->QueryGetData(&fmt) == S_OK);
  60. }
  61. COM_PROTECT_CATCH;
  62. return bMultiSelect;
  63. }
  64. // Data object extraction helpers
  65. CLSID* ExtractClassID(LPDATAOBJECT lpDataObject)
  66. {
  67. return Extract<CLSID>(lpDataObject, (CLIPFORMAT) s_cfCoClass, -1);
  68. }
  69. GUID* ExtractNodeType(LPDATAOBJECT lpDataObject)
  70. {
  71. return Extract<GUID>(lpDataObject, (CLIPFORMAT) s_cfNodeType, -1);
  72. }
  73. INTERNAL* ExtractInternalFormat(LPDATAOBJECT lpDataObject)
  74. {
  75. return Extract<INTERNAL>(lpDataObject, (CLIPFORMAT) s_cfInternal, -1);
  76. }
  77. TFSCORE_API(WCHAR*) ExtractComputerName(LPDATAOBJECT lpDataObject)
  78. {
  79. return Extract<WCHAR>(lpDataObject, (CLIPFORMAT) s_cfComputerName, (MAX_PATH+1) * sizeof(WCHAR));
  80. }