コード例 #1
0
        public void RemoveInstalledProperty(string canonicalName)
        {
            var index = CustomProperties.FindIndex(p => p.CanonicalName == canonicalName);

            if (index != -1)
            {
                CustomProperties.RemoveAt(index);
            }
            DictInstalledProperties.Remove(canonicalName);
        }
コード例 #2
0
        private void PopulatePropertyList(List <PropertyConfig> propertyList,
                                          PropertySystemNativeMethods.PropDescEnumFilter filter)
        {
            propertyList.Clear();
            IPropertyDescriptionList propertyDescriptionList = null;
            IPropertyDescription     propertyDescription     = null;
            Guid guid = new Guid(ShellIIDGuid.IPropertyDescriptionList);

            try
            {
                var hr = PropertySystemNativeMethods.PSEnumeratePropertyDescriptions(
                    filter, ref guid, out propertyDescriptionList);
                if (hr >= 0)
                {
                    propertyDescriptionList.GetCount(out uint count);
                    guid = new Guid(ShellIIDGuid.IPropertyDescription);

                    for (uint i = 0; i < count; i++)
                    {
                        propertyDescriptionList.GetAt(i, ref guid, out propertyDescription);

                        if (propertyDescription != null)
                        {
                            var shellProperty = new ShellPropertyDescription(propertyDescription);
                            var pc            = new PropertyConfig(shellProperty);
                            shellProperty.Dispose();        // Releases propertyDescription
                            propertyDescription = null;
                            GetInstalledProperty(pc, true); // Add search and alias info
                            propertyList.Add(pc);
                            DictInstalledProperties.Add(pc.CanonicalName, pc);
                        }
                    }
                }
            }
            finally
            {
                if (propertyDescriptionList != null)
                {
                    Marshal.ReleaseComObject(propertyDescriptionList);
                }
                if (propertyDescription != null)
                {
                    Marshal.ReleaseComObject(propertyDescription);
                }
            }
        }