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.

106 lines
2.3 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 "XFileReferenceObj.h"
  16. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  17. extern BSTR GUIDtoBSTR(LPGUID);
  18. extern HRESULT XFILEBSTRtoGUID(LPGUID,BSTR);
  19. extern BSTR XFILEGUIDtoBSTR(LPGUID);
  20. C_dxj_DirectXFileReferenceObject::C_dxj_DirectXFileReferenceObject()
  21. {
  22. m_pXFileReference=NULL;
  23. }
  24. C_dxj_DirectXFileReferenceObject::~C_dxj_DirectXFileReferenceObject()
  25. {
  26. if (m_pXFileReference) m_pXFileReference->Release();
  27. }
  28. HRESULT C_dxj_DirectXFileReferenceObject::create( IDirectXFileDataReference *pRef,I_dxj_DirectXFileReference **ret)
  29. {
  30. HRESULT hr;
  31. if (!ret) return E_INVALIDARG;
  32. C_dxj_DirectXFileReferenceObject *c=NULL;
  33. c=new CComObject<C_dxj_DirectXFileReferenceObject>;
  34. if( c == NULL ) return E_OUTOFMEMORY;
  35. c->Init(pRef);
  36. hr=IUNK(c)->QueryInterface(IID_I_dxj_DirectXFileReference, (void**)ret);
  37. return hr;
  38. }
  39. HRESULT C_dxj_DirectXFileReferenceObject::Init(IDirectXFileDataReference *pRef)
  40. {
  41. m_pXFileReference=pRef;
  42. return S_OK;
  43. }
  44. STDMETHODIMP C_dxj_DirectXFileReferenceObject::GetName(
  45. /* [retval][out] */ BSTR __RPC_FAR *name)
  46. {
  47. HRESULT hr;
  48. USES_CONVERSION;
  49. char szName[1024];
  50. DWORD dwSize=1024;
  51. hr=m_pXFileReference->GetName(szName,&dwSize);
  52. if FAILED(hr) return hr;
  53. *name=T2BSTR(szName);
  54. return S_OK;
  55. }
  56. STDMETHODIMP C_dxj_DirectXFileReferenceObject::GetId(
  57. /* [retval][out] */ BSTR __RPC_FAR *name)
  58. {
  59. HRESULT hr;
  60. GUID g;
  61. ZeroMemory(&g,sizeof(GUID));
  62. hr=m_pXFileReference->GetId(&g);
  63. if FAILED(hr) return hr;
  64. *name=XFILEGUIDtoBSTR(&g);
  65. return hr;
  66. }
  67. HRESULT C_dxj_DirectXFileReferenceObject::Resolve(
  68. /* [retval][out] */ I_dxj_DirectXFileData __RPC_FAR *__RPC_FAR *obj)
  69. {
  70. HRESULT hr;
  71. IDirectXFileData *pData=NULL;
  72. hr=m_pXFileReference->Resolve(&pData);
  73. if FAILED(hr) return hr;
  74. if (!pData)
  75. {
  76. *obj=NULL;
  77. return S_OK;
  78. }
  79. hr=C_dxj_DirectXFileDataObject::create(pData,obj);
  80. return hr;
  81. }