Beispiel #1
0
        public PropertyDescription GetPropertyDescription(PROPERTYKEY propKey)
        {
            Guid IID_IPropertyDescription = typeof(NativeMethods.IPropertyDescription).GUID;

            NativeMethods.IPropertyDescription iPropertyDescription;
            m_IPropertySystem.GetPropertyDescription(propKey, ref IID_IPropertyDescription, out iPropertyDescription);
            return(new PropertyDescription(iPropertyDescription));
        }
Beispiel #2
0
        public void SetValue(PROPERTYKEY key, object value)
        {
            IntPtr pv = IntPtr.Zero;

            try
            {
                pv = NativeMethods.PropVariantFromObject(value);
                m_IPropertyStore.SetValue(key, pv);
            }
            finally
            {
                if (pv != IntPtr.Zero)
                {
                    NativeMethods.PropVariantClear(pv);
                    Marshal.FreeCoTaskMem(pv);
                    pv = IntPtr.Zero;
                }
            }
        }
Beispiel #3
0
        public object GetValue(PROPERTYKEY key)
        {
            IntPtr pv    = IntPtr.Zero;
            object value = null;

            try
            {
                pv = Marshal.AllocCoTaskMem(16);
                m_IPropertyStore.GetValue(key, pv);
                try
                {
                    value = PropVariant.ToObject(pv);
                }
                catch (Exception err)
                {
                    throw new ApplicationException("Unsupported property data type", err);
                }
            }
            finally
            {
                if (pv != (IntPtr)0)
                {
                    try
                    {
                        NativeMethods.PropVariantClear(pv);
                    }
                    catch
                    {
                        Debug.Fail("VariantClear failure");
                    }
                    Marshal.FreeCoTaskMem(pv);
                    pv = IntPtr.Zero;
                }
            }
            return(value);
        }
 public void SetValue(PROPERTYKEY key, object value)
 {
     IntPtr pv = IntPtr.Zero;
     try
     {
         pv = NativeMethods.PropVariantFromObject(value);
         m_IPropertyStore.SetValue(key, pv);
     }
     finally
     {
         if (pv != IntPtr.Zero)
         {
             NativeMethods.PropVariantClear(pv);
             Marshal.FreeCoTaskMem(pv);
             pv = IntPtr.Zero;
         }
     }
 }
 public object GetValue(PROPERTYKEY key)
 {
     IntPtr pv = IntPtr.Zero;
     object value = null;
     try
     {
         pv = Marshal.AllocCoTaskMem(16);
         m_IPropertyStore.GetValue(key, pv);
         try
         {
             value = PropVariant.ToObject(pv);
         }
         catch (Exception err)
         {
             throw new ApplicationException("Unsupported property data type", err);
         }
     }
     finally
     {
         if (pv != (IntPtr)0)
         {
             try
             {
                 NativeMethods.PropVariantClear(pv);
             }
             catch
             {
                 Debug.Fail("VariantClear failure");
             }
             Marshal.FreeCoTaskMem(pv);
             pv = IntPtr.Zero;
         }
     }
     return value;
 }
 public PropertyDescription GetPropertyDescription(PROPERTYKEY propKey)
 {
     Guid IID_IPropertyDescription = typeof(NativeMethods.IPropertyDescription).GUID;
     NativeMethods.IPropertyDescription iPropertyDescription;
     m_IPropertySystem.GetPropertyDescription(propKey, ref IID_IPropertyDescription, out iPropertyDescription);
     return new PropertyDescription(iPropertyDescription);
 }