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.

136 lines
2.7 KiB

  1. //+-------------------------------------------------------------------------
  2. //
  3. // Microsoft Windows
  4. //
  5. // Copyright (C) Microsoft Corporation, 1998 - 1999
  6. //
  7. // File: dpmsgobj.cpp
  8. //
  9. //--------------------------------------------------------------------------
  10. #include "stdafx.h"
  11. #include "Direct.h"
  12. #include "dms.h"
  13. #include "dxfile.h"
  14. #include "XfileDataObj.h"
  15. #include "XfileEnumObj.h"
  16. extern HRESULT XFILEBSTRtoGUID(LPGUID,BSTR);
  17. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  18. extern BSTR GUIDtoBSTR(LPGUID);
  19. C_dxj_DirectXFileEnumObject::C_dxj_DirectXFileEnumObject()
  20. {
  21. m_pXFileEnum=NULL;
  22. }
  23. C_dxj_DirectXFileEnumObject::~C_dxj_DirectXFileEnumObject()
  24. {
  25. if (m_pXFileEnum) m_pXFileEnum->Release();
  26. }
  27. HRESULT C_dxj_DirectXFileEnumObject::create( IDirectXFileEnumObject *pEnum,I_dxj_DirectXFileEnum **ret)
  28. {
  29. HRESULT hr;
  30. if (!ret) return E_INVALIDARG;
  31. //caller must addref
  32. C_dxj_DirectXFileEnumObject *c=NULL;
  33. c=new CComObject<C_dxj_DirectXFileEnumObject>;
  34. if( c == NULL ) return E_OUTOFMEMORY;
  35. c->Init(pEnum);
  36. hr=c->QueryInterface(IID_I_dxj_DirectXFileEnum, (void**)ret);
  37. return hr;
  38. }
  39. HRESULT C_dxj_DirectXFileEnumObject::Init( IDirectXFileEnumObject *pEnum)
  40. {
  41. m_pXFileEnum=pEnum;
  42. return S_OK;
  43. }
  44. STDMETHODIMP C_dxj_DirectXFileEnumObject::GetNextDataObject(
  45. /* [retval][out] */ I_dxj_DirectXFileData __RPC_FAR *__RPC_FAR *ret)
  46. {
  47. HRESULT hr;
  48. IDirectXFileData *pXFData=NULL;
  49. hr=m_pXFileEnum->GetNextDataObject(&pXFData);
  50. if (hr==DXFILEERR_NOMOREOBJECTS){
  51. *ret=NULL;
  52. return S_OK;
  53. }
  54. if FAILED(hr) return hr;
  55. if (pXFData==NULL) {
  56. *ret=NULL;
  57. return S_OK;
  58. }
  59. hr=C_dxj_DirectXFileDataObject::create(pXFData,ret);
  60. if FAILED(hr) pXFData->Release();
  61. return hr;
  62. }
  63. STDMETHODIMP C_dxj_DirectXFileEnumObject::GetDataObjectById(
  64. /* [in] */ BSTR id,
  65. I_dxj_DirectXFileData __RPC_FAR *__RPC_FAR *ret)
  66. {
  67. HRESULT hr;
  68. GUID g;
  69. ZeroMemory(&g,sizeof(GUID));
  70. hr=XFILEBSTRtoGUID(&g,id);
  71. if FAILED(hr) return hr;
  72. IDirectXFileData *pXFData=NULL;
  73. hr=m_pXFileEnum->GetDataObjectById(g,&pXFData);
  74. if FAILED(hr) return hr;
  75. if (pXFData==NULL) {
  76. *ret=NULL;
  77. return S_OK;
  78. }
  79. hr=C_dxj_DirectXFileDataObject::create(pXFData,ret);
  80. if FAILED(hr) pXFData->Release();
  81. return hr;
  82. }
  83. STDMETHODIMP C_dxj_DirectXFileEnumObject::GetDataObjectByName(
  84. /* [in] */ BSTR id,
  85. I_dxj_DirectXFileData __RPC_FAR *__RPC_FAR *ret)
  86. {
  87. USES_CONVERSION;
  88. HRESULT hr;
  89. LPSTR szName=W2T(id);
  90. IDirectXFileData *pXFData=NULL;
  91. hr=m_pXFileEnum->GetDataObjectByName(szName,&pXFData);
  92. if FAILED(hr) return hr;
  93. if (pXFData==NULL) {
  94. *ret=NULL;
  95. return S_OK;
  96. }
  97. hr=C_dxj_DirectXFileDataObject::create(pXFData,ret);
  98. if FAILED(hr) pXFData->Release();
  99. return hr;
  100. }