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.

84 lines
1.8 KiB

  1. /*
  2. * comcpp.cpp - Common C++ functions implementation.
  3. */
  4. /* Headers
  5. **********/
  6. #include "project.hpp"
  7. #pragma hdrstop
  8. /****************************** Public Functions *****************************/
  9. PUBLIC_CODE HRESULT MyReleaseStgMedium(PSTGMEDIUM pstgmed)
  10. {
  11. HRESULT hr;
  12. ASSERT(IS_VALID_STRUCT_PTR(pstgmed, CSTGMEDIUM));
  13. if (pstgmed->pUnkForRelease)
  14. {
  15. hr = pstgmed->pUnkForRelease->Release();
  16. switch(pstgmed->tymed)
  17. {
  18. case TYMED_FILE:
  19. SHFree(pstgmed->lpszFileName);
  20. hr = S_OK;
  21. break;
  22. case TYMED_ISTREAM:
  23. hr = pstgmed->pstm->Release();
  24. break;
  25. case TYMED_ISTORAGE:
  26. hr = pstgmed->pstm->Release();
  27. break;
  28. }
  29. }
  30. else
  31. {
  32. switch(pstgmed->tymed)
  33. {
  34. case TYMED_HGLOBAL:
  35. hr = (! GlobalFree(pstgmed->hGlobal)) ? S_OK : E_HANDLE;
  36. break;
  37. case TYMED_ISTREAM:
  38. hr = pstgmed->pstm->Release();
  39. break;
  40. case TYMED_ISTORAGE:
  41. hr = pstgmed->pstm->Release();
  42. break;
  43. case TYMED_FILE:
  44. SHFree(pstgmed->lpszFileName);
  45. hr = S_OK;
  46. break;
  47. case TYMED_GDI:
  48. hr = (DeleteObject(pstgmed->hBitmap)) ? S_OK : E_HANDLE;
  49. break;
  50. case TYMED_MFPICT:
  51. hr = (DeleteMetaFile((HMETAFILE)(pstgmed->hMetaFilePict)) &&
  52. ! GlobalFree(pstgmed->hMetaFilePict)) ? S_OK : E_HANDLE;
  53. break;
  54. case TYMED_ENHMF:
  55. hr = (DeleteEnhMetaFile(pstgmed->hEnhMetaFile)) ? S_OK : E_HANDLE;
  56. break;
  57. default:
  58. ASSERT(pstgmed->tymed == TYMED_NULL);
  59. hr = S_OK;
  60. break;
  61. }
  62. }
  63. return(hr);
  64. }