示例#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));
        }
示例#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;
                }
            }
        }
示例#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);
        }
示例#4
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;
         }
     }
 }
示例#5
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;
 }
示例#6
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);
 }