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.

96 lines
2.8 KiB

  1. /**********************************************************************/
  2. /** Microsoft Windows/NT **/
  3. /** Copyright(c) Microsoft Corporation, 1997 - 1999 **/
  4. /**********************************************************************/
  5. /*
  6. rtrdata.cpp
  7. Implementation for data objects in the MMC
  8. FILE HISTORY:
  9. */
  10. #include "stdafx.h"
  11. #include "rtrdata.h"
  12. #include "extract.h"
  13. #ifdef _DEBUG
  14. #define new DEBUG_NEW
  15. #undef THIS_FILE
  16. static char THIS_FILE[] = __FILE__;
  17. #endif
  18. ///////////////////////////////////////////////////////////////////////////////
  19. // Sample code to show how to Create DataObjects
  20. // Minimal error checking for clarity
  21. // Clipboard formats
  22. unsigned int CRouterDataObject::m_cfComputerName = RegisterClipboardFormat(L"MMC_SNAPIN_MACHINE_NAME");
  23. unsigned int CRouterDataObject::m_cfComputerAddedAsLocal = RegisterClipboardFormat(L"MMC_MPRSNAP_COMPUTERADDEDASLOCAL");
  24. /////////////////////////////////////////////////////////////////////////////
  25. // CRouterDataObject implementations
  26. DEBUG_DECLARE_INSTANCE_COUNTER(CRouterDataObject);
  27. HRESULT CRouterDataObject::GetMoreDataHere(LPFORMATETC lpFormatetc, LPSTGMEDIUM lpMedium)
  28. {
  29. HRESULT hr = DV_E_CLIPFORMAT;
  30. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  31. // Based on the CLIPFORMAT write data to the stream
  32. const CLIPFORMAT cf = lpFormatetc->cfFormat;
  33. if (cf == m_cfComputerName)
  34. {
  35. hr = CreateComputerName(lpMedium);
  36. }
  37. else if (cf == m_cfComputerAddedAsLocal)
  38. hr = CreateComputerAddedAsLocal(lpMedium);
  39. return hr;
  40. }
  41. HRESULT CRouterDataObject::QueryGetMoreData(LPFORMATETC lpFormatEtc)
  42. {
  43. HRESULT hr = E_INVALIDARG;
  44. // of these then return invalid.
  45. if ((lpFormatEtc->cfFormat == m_cfComputerName) ||
  46. (lpFormatEtc->cfFormat == m_cfComputerAddedAsLocal))
  47. hr = S_OK;
  48. return hr;
  49. }
  50. /////////////////////////////////////////////////////////////////////////////
  51. // CRouterDataObject creation members
  52. void CRouterDataObject::SetComputerName(LPCTSTR pszComputerName)
  53. {
  54. m_stComputerName = pszComputerName;
  55. }
  56. HRESULT CRouterDataObject::CreateComputerName(LPSTGMEDIUM lpMedium)
  57. {
  58. AFX_MANAGE_STATE(AfxGetStaticModuleState());
  59. USES_CONVERSION;
  60. LPCWSTR pswz = T2CW((LPCTSTR) m_stComputerName);
  61. // Create the computer name object
  62. return Create(pswz, (StrLenW(pswz)+1) * sizeof(WCHAR), lpMedium);
  63. }
  64. void CRouterDataObject::SetComputerAddedAsLocal(BOOL fComputerAddedAsLocal)
  65. {
  66. m_fComputerAddedAsLocal = fComputerAddedAsLocal;
  67. }
  68. HRESULT CRouterDataObject::CreateComputerAddedAsLocal(LPSTGMEDIUM lpMedium)
  69. {
  70. return Create(&m_fComputerAddedAsLocal, sizeof(m_fComputerAddedAsLocal),
  71. lpMedium);
  72. }