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.

114 lines
4.5 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1997 - 2000
  6. //
  7. // File: pcrack.h
  8. //
  9. // requires iads.h (IADsPathname) and atlbase.h (CComPtr)
  10. //
  11. //--------------------------------------------------------------------------
  12. // pcrack.h : include file for CPathCracker
  13. #ifndef __PCRACK_H__
  14. #define __PCRACK_H__
  15. //+--------------------------------------------------------------------------
  16. //
  17. // Class: CPathCracker
  18. //
  19. // Purpose: A wrapper around the IADsPathname interface with additional
  20. // methods for manipulating paths.
  21. // The constructor creates the object and the destructor releases it.
  22. // This object is meant to be created on the stack and then it
  23. // is cleaned up when it goes out of scope
  24. //
  25. // History: 6-Sep-2000 JeffJon Created
  26. //
  27. //---------------------------------------------------------------------------
  28. class CPathCracker
  29. {
  30. public:
  31. //
  32. // Constructor
  33. //
  34. CPathCracker();
  35. //
  36. // IADsPathname methods
  37. //
  38. virtual /* [id] */ HRESULT STDMETHODCALLTYPE Set(
  39. /* [in] */ const BSTR bstrADsPath,
  40. /* [in] */ long lnSetType)
  41. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->Set(bstrADsPath, lnSetType); }
  42. virtual /* [id] */ HRESULT STDMETHODCALLTYPE SetDisplayType(
  43. /* [in] */ long lnDisplayType)
  44. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->SetDisplayType(lnDisplayType); }
  45. virtual /* [id] */ HRESULT STDMETHODCALLTYPE Retrieve(
  46. /* [in] */ long lnFormatType,
  47. /* [retval][out] */ BSTR __RPC_FAR *pbstrADsPath)
  48. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->Retrieve(lnFormatType, pbstrADsPath); }
  49. virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetNumElements(
  50. /* [retval][out] */ long __RPC_FAR *plnNumPathElements)
  51. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->GetNumElements(plnNumPathElements); }
  52. virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetElement(
  53. /* [in] */ long lnElementIndex,
  54. /* [retval][out] */ BSTR __RPC_FAR *pbstrElement)
  55. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->GetElement(lnElementIndex, pbstrElement); }
  56. virtual /* [id] */ HRESULT STDMETHODCALLTYPE AddLeafElement(
  57. /* [in] */ BSTR bstrLeafElement)
  58. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->AddLeafElement(bstrLeafElement); }
  59. virtual /* [id] */ HRESULT STDMETHODCALLTYPE RemoveLeafElement( void)
  60. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->RemoveLeafElement(); }
  61. virtual /* [id] */ HRESULT STDMETHODCALLTYPE CopyPath(
  62. /* [retval][out] */ IDispatch __RPC_FAR *__RPC_FAR *ppAdsPath)
  63. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->CopyPath(ppAdsPath); }
  64. virtual /* [id] */ HRESULT STDMETHODCALLTYPE GetEscapedElement(
  65. /* [in] */ long lnReserved,
  66. /* [in] */ const BSTR bstrInStr,
  67. /* [retval][out] */ BSTR __RPC_FAR *pbstrOutStr)
  68. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->GetEscapedElement(lnReserved, bstrInStr, pbstrOutStr); }
  69. virtual /* [id][propget] */ HRESULT STDMETHODCALLTYPE get_EscapedMode(
  70. /* [retval][out] */ long __RPC_FAR *retval)
  71. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->get_EscapedMode(retval); }
  72. virtual /* [id][propput] */ HRESULT STDMETHODCALLTYPE put_EscapedMode(
  73. /* [in] */ long lnEscapedMode)
  74. { return (m_spIADsPathname == NULL) ? m_hrCreate : m_spIADsPathname->put_EscapedMode(lnEscapedMode); }
  75. //
  76. // Other helpful path manglers
  77. //
  78. static HRESULT GetParentDN(PCWSTR pszDN,
  79. CComBSTR& refsbstrDN);
  80. static HRESULT GetObjectRDNFromDN(PCWSTR pszDN,
  81. CComBSTR& refsbstrRDN);
  82. static HRESULT GetObjectNameFromDN(PCWSTR pszDN,
  83. CComBSTR& refsbstrName);
  84. static HRESULT GetDNFromPath(PCWSTR pszPath,
  85. CComBSTR& refsbstrDN);
  86. private:
  87. //
  88. // Private member function
  89. //
  90. HRESULT Init();
  91. //
  92. // Private member data
  93. //
  94. CComPtr<IADsPathname> m_spIADsPathname;
  95. HRESULT m_hrCreate;
  96. };
  97. #endif _PCRACK_H_