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.

56 lines
1.6 KiB

  1. /////////////////////////////////////////////////////////////////////////////
  2. //
  3. // propertybag2impl.h : helper functions for implementing IPropertyBag2
  4. // Copyright (c) Microsoft Corporation 1999.
  5. //
  6. // this code assumes that you're also implementing IPropertyBag and reflects
  7. // bag2's read/write to bag's read/write
  8. //
  9. template <class T>
  10. class ATL_NO_VTABLE IPropertyBag2Impl : public IPropertyBag2
  11. {
  12. // IPropertyBag2
  13. STDMETHOD(Read)(ULONG cProperties, PROPBAG2* pPropBag, IErrorLog* pErrLog, VARIANT* pvarValue, HRESULT* phrError) {
  14. HRESULT hrc = NOERROR;
  15. if (!phrError || !pPropBag) {
  16. return E_POINTER;
  17. }
  18. try {
  19. ATL_LOCKT();
  20. for (ULONG i = 0; i < cProperties; ++i) {
  21. phrError[i] = pT->Read(pPropBag[i].pstrName, pvarValue + i, pErrLog);
  22. if (FAILED(phrError[i])) {
  23. hrc = E_FAIL;
  24. }
  25. }
  26. return hrc;
  27. } catch (...) {
  28. return E_UNEXPECTED;
  29. }
  30. }
  31. STDMETHOD(Write)(ULONG cProperties, PROPBAG2* pPropBag, VARIANT* pvarValue) {
  32. HRESULT hrc = NOERROR;
  33. if (!pvarValue || !pPropBag) {
  34. return E_POINTER;
  35. }
  36. try {
  37. ATL_LOCKT();
  38. for (ULONG i = 0; i < cProperties; ++i) {
  39. VARIANT *pVAR = pvarValue + i;
  40. LPCOLESTR s = pPropBag[i].pstrName;
  41. HRESULT hr = pT->Write(s, pVAR);
  42. if (FAILED(hr)) {
  43. hrc = E_FAIL;
  44. }
  45. }
  46. return hrc;
  47. } catch (...) {
  48. return E_UNEXPECTED;
  49. }
  50. }
  51. };