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.

139 lines
2.5 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 "XFileBinaryObj.h"
  15. extern HRESULT BSTRtoGUID(LPGUID,BSTR);
  16. extern BSTR GUIDtoBSTR(LPGUID);
  17. extern BSTR XFILEGUIDtoBSTR(LPGUID);
  18. C_dxj_DirectXFileBinaryObject::C_dxj_DirectXFileBinaryObject()
  19. {
  20. m_pXFileBinary=NULL;
  21. }
  22. C_dxj_DirectXFileBinaryObject::~C_dxj_DirectXFileBinaryObject()
  23. {
  24. if (m_pXFileBinary) m_pXFileBinary->Release();
  25. }
  26. HRESULT C_dxj_DirectXFileBinaryObject::create(IDirectXFileBinary *pBin,I_dxj_DirectXFileBinary **ret)
  27. {
  28. HRESULT hr;
  29. if (!ret) return E_INVALIDARG;
  30. C_dxj_DirectXFileBinaryObject *c=NULL;
  31. c=new CComObject<C_dxj_DirectXFileBinaryObject>;
  32. if( c == NULL ) return E_OUTOFMEMORY;
  33. c->Init(pBin);
  34. hr=c->QueryInterface(IID_I_dxj_DirectXFileBinary, (void**)ret);
  35. return hr;
  36. }
  37. HRESULT C_dxj_DirectXFileBinaryObject::Init(IDirectXFileBinary *pBin)
  38. {
  39. m_pXFileBinary=pBin;
  40. return S_OK;
  41. }
  42. STDMETHODIMP C_dxj_DirectXFileBinaryObject::GetName(
  43. /* [retval][out] */ BSTR __RPC_FAR *name)
  44. {
  45. HRESULT hr;
  46. USES_CONVERSION;
  47. char szName[1024];
  48. DWORD dwSize=1024;
  49. hr=m_pXFileBinary->GetName(szName,&dwSize);
  50. if FAILED(hr) return hr;
  51. *name=T2BSTR(szName);
  52. return S_OK;
  53. }
  54. STDMETHODIMP C_dxj_DirectXFileBinaryObject::GetId(
  55. /* [retval][out] */ BSTR __RPC_FAR *name)
  56. {
  57. HRESULT hr;
  58. GUID g;
  59. ZeroMemory(&g,sizeof(GUID));
  60. hr=m_pXFileBinary->GetId(&g);
  61. if FAILED(hr) return hr;
  62. *name=XFILEGUIDtoBSTR(&g);
  63. return hr;
  64. }
  65. STDMETHODIMP C_dxj_DirectXFileBinaryObject::GetSize(
  66. /* [retval][out] */ long __RPC_FAR *size)
  67. {
  68. HRESULT hr;
  69. hr=m_pXFileBinary->GetSize((DWORD*)size);
  70. return hr;
  71. }
  72. HRESULT C_dxj_DirectXFileBinaryObject::GetMimeType(
  73. /* [retval][out] */ BSTR __RPC_FAR *mime)
  74. {
  75. {
  76. HRESULT hr;
  77. USES_CONVERSION;
  78. const char **ppMime=NULL;
  79. hr=m_pXFileBinary->GetMimeType(ppMime);
  80. if FAILED(hr) return hr;
  81. if (!ppMime) return E_FAIL;
  82. *mime=T2BSTR(*ppMime);
  83. return S_OK;
  84. }
  85. }
  86. HRESULT C_dxj_DirectXFileBinaryObject::Read(
  87. /* [out][in] */ void __RPC_FAR *data,
  88. /* [in] */ long size,
  89. /* [retval][out] */ long __RPC_FAR *read)
  90. {
  91. HRESULT hr;
  92. __try
  93. {
  94. hr=m_pXFileBinary->Read(data,(DWORD)size,(DWORD*)read);
  95. }
  96. __except(1,1)
  97. {
  98. return E_INVALIDARG;
  99. }
  100. return hr;
  101. }