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.

89 lines
1.8 KiB

  1. #include "stdafx.h"
  2. #include "guidedb.h"
  3. #include "stdprop.h"
  4. IMetaPropertyType *CStdPropSet::GetMetaPropertyType(long id, const char *szName)
  5. {
  6. HRESULT hr;
  7. IMetaPropertyType *pproptype = NULL;
  8. if (m_ppropset == NULL)
  9. {
  10. hr = m_ppropsets->get_ItemWithName(m_bstrName, &m_ppropset);
  11. if (FAILED(hr))
  12. {
  13. hr = m_ppropsets->get_AddNew(m_bstrName, &m_ppropset);
  14. if (FAILED(hr))
  15. return NULL;
  16. }
  17. }
  18. CComPtr<IMetaPropertyTypes> pproptypes;
  19. hr = m_ppropset->get_MetaPropertyTypes(&pproptypes);
  20. if (FAILED(hr))
  21. return NULL;
  22. hr = pproptypes->get_ItemWithID(id, &pproptype);
  23. if (FAILED(hr))
  24. {
  25. _bstr_t bstr(szName);
  26. _variant_t varNil;
  27. hr = pproptypes->get_AddNew(id, bstr, &pproptype);
  28. if (FAILED(hr))
  29. return NULL;
  30. }
  31. return pproptype;
  32. };
  33. IMetaProperty *CStdPropSet::GetMetaProperty(IUnknown *pobj, IMetaPropertyType *pproptype, long lang)
  34. {
  35. HRESULT hr;
  36. CComPtr<IMetaProperties> pprops;
  37. CComPtr<CGuideDB> pdb;
  38. hr = GetDB(&pdb);
  39. if (FAILED(hr))
  40. return NULL;
  41. hr = pdb->get_MetaPropertiesOf(pobj, &pprops);
  42. if (FAILED(hr))
  43. return NULL;
  44. CComPtr<IMetaProperty> pprop;
  45. hr = pprops->get_ItemWith(pproptype, lang, &pprop);
  46. if (FAILED(hr))
  47. {
  48. _variant_t varNil;
  49. hr = pprops->get_AddNew(pproptype, lang, varNil, &pprop);
  50. if (FAILED(hr))
  51. return NULL;
  52. }
  53. return pprop.Detach();
  54. }
  55. HRESULT CStdPropSet::GetMetaPropertyValue(IUnknown *pobj, IMetaPropertyType *pproptype, VARIANT *pvarValue)
  56. {
  57. CComPtr<IMetaProperty> pprop = GetMetaProperty(pobj, pproptype);
  58. if (pprop == NULL)
  59. return E_INVALIDARG;
  60. return pprop->get_Value(pvarValue);
  61. }
  62. HRESULT CStdPropSet::PutMetaPropertyValue(IUnknown *pobj, IMetaPropertyType *pproptype, VARIANT varValue)
  63. {
  64. CComPtr<IMetaProperty> pprop = GetMetaProperty(pobj, pproptype);
  65. if (pprop == NULL)
  66. return E_INVALIDARG;
  67. return pprop->put_Value(varValue);
  68. }