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.

75 lines
1.8 KiB

  1. // PropItem.h : Declaration of the CPropertyItem
  2. #ifndef __PROPERTYITEM_H_
  3. #define __PROPERTYITEM_H_
  4. #include "resource.h" // main symbols
  5. #include "pppbag.h"
  6. /////////////////////////////////////////////////////////////////////////////
  7. // CPropertyItem
  8. class ATL_NO_VTABLE CPropertyItem :
  9. public CComObjectRootEx<CComSingleThreadModel>,
  10. public IDispatchImpl<IPropertyItem, &IID_IPropertyItem, &LIBID_WIZCHAINLib>
  11. {
  12. private:
  13. VARIANT m_var;
  14. PPPBAG_TYPE m_dwFlags;
  15. BSTR m_bstrName;
  16. public:
  17. CPropertyItem( )
  18. {
  19. VariantInit (&m_var);
  20. m_dwFlags = PPPBAG_TYPE_UNINITIALIZED;
  21. m_bstrName = NULL;
  22. }
  23. HRESULT Initialize( BSTR bstrName, VARIANT * v, PPPBAG_TYPE dwFlags )
  24. {
  25. // should be called only once
  26. assert (m_bstrName == NULL);
  27. assert (m_var.vt == VT_EMPTY);
  28. HRESULT hr = S_OK;
  29. m_dwFlags = dwFlags;
  30. hr = VariantCopy( &m_var, v );
  31. if( hr == S_OK )
  32. {
  33. if( !(m_bstrName = SysAllocString (bstrName)) )
  34. {
  35. hr = E_OUTOFMEMORY;
  36. }
  37. }
  38. return hr;
  39. }
  40. ~CPropertyItem( )
  41. {
  42. VariantClear( &m_var );
  43. if( m_bstrName )
  44. {
  45. SysFreeString( m_bstrName );
  46. }
  47. }
  48. DECLARE_PROTECT_FINAL_CONSTRUCT()
  49. BEGIN_COM_MAP(CPropertyItem)
  50. COM_INTERFACE_ENTRY(IPropertyItem)
  51. COM_INTERFACE_ENTRY(IDispatch)
  52. END_COM_MAP()
  53. // IPropertyItem
  54. public:
  55. virtual HRESULT STDMETHODCALLTYPE get_Value( /*[out, retval]*/ VARIANT *varValue );
  56. virtual HRESULT STDMETHODCALLTYPE get_Name ( /*[out, retval]*/ BSTR *strName );
  57. virtual HRESULT STDMETHODCALLTYPE get_Type ( /*[out, retval]*/ long *dwFlags );
  58. };
  59. #endif //__PROPERTYITEM_H_