private void PopulateSystemProperties() { IPropertyDescriptionList propertyDescriptionList = null; IPropertyDescription propertyDescription = null; Guid guid = new Guid(ShellIIDGuid.IPropertyDescriptionList); try { int hr = PropertySystemNativeMethods.PSEnumeratePropertyDescriptions(PropertySystemNativeMethods.PropDescEnumFilter.PDEF_ALL, ref guid, out propertyDescriptionList); if (hr >= 0) { uint count; propertyDescriptionList.GetCount(out count); guid = new Guid(ShellIIDGuid.IPropertyDescription); Dictionary <string, List <string> > dict = new Dictionary <string, List <string> >(); for (uint i = 0; i < count; i++) { propertyDescriptionList.GetAt(i, ref guid, out propertyDescription); var spd = new ShellPropertyDescription(propertyDescription); propDescs.Add(spd); propDescDict.Add(spd.CanonicalName, spd); } } } finally { if (propertyDescriptionList != null) { Marshal.ReleaseComObject(propertyDescriptionList); } } }
} // private void ReadFileDetails(string path) { using (ShellObject shellObj = ShellObject.FromParsingName(path)) { using (ShellProperties props = shellObj.Properties) { this.WriteProperties(props); IShellProperty shellProp = props.GetProperty(SystemProperties.System.Category); ShellPropertyDescription desc = SystemProperties.GetPropertyDescription(SystemProperties.System.Category); Console.WriteLine("Prop value: " + desc.ValueType); } } }
private static void ShowPropertyInfo(string propertyName, ShellPropertyDescription propDesc) { Console.WriteLine("\nProperty {0}", propDesc.CanonicalName); Console.WriteLine("\tPropertyKey: {0}, {1}", propDesc.PropertyKey.FormatId.ToString("B"), propDesc.PropertyKey.PropertyId); Console.WriteLine("\tLabel: {0}", propDesc.DisplayName); Console.WriteLine("\tEdit Invitation: {0}", propDesc.EditInvitation); Console.WriteLine("\tDisplay Type: {0}", propDesc.DisplayType); Console.WriteLine("\tVar Enum Type: {0}", propDesc.VarEnumType); Console.WriteLine("\tValue Type: {0}", propDesc.ValueType); Console.WriteLine("\tDefault Column Width: {0}", propDesc.DefaultColumWidth); Console.WriteLine("\tAggregation Type: {0}", propDesc.AggregationTypes); Console.WriteLine("\tHas Multiple Values: {0}", (propDesc.TypeFlags & PropertyTypeOptions.MultipleValues) == PropertyTypeOptions.MultipleValues); Console.WriteLine("\tIs Group: {0}", (propDesc.TypeFlags & PropertyTypeOptions.IsGroup) == PropertyTypeOptions.IsGroup); Console.WriteLine("\tIs Innate: {0}", (propDesc.TypeFlags & PropertyTypeOptions.IsInnate) == PropertyTypeOptions.IsInnate); Console.WriteLine("\tIs Queryable: {0}", (propDesc.TypeFlags & PropertyTypeOptions.IsQueryable) == PropertyTypeOptions.IsQueryable); Console.WriteLine("\tIs Viewable: {0}", (propDesc.TypeFlags & PropertyTypeOptions.IsViewable) == PropertyTypeOptions.IsViewable); Console.WriteLine("\tIs SystemProperty: {0}", (propDesc.TypeFlags & PropertyTypeOptions.IsSystemProperty) == PropertyTypeOptions.IsSystemProperty); }
/// <summary> /// This method collects the canonical names of all properties /// that are reflected from the given list of types. /// </summary> public void collectCanonicalNames(List <Type> types) { foreach (Type type in types) { PropertyInfo[] properties = type.GetProperties(); foreach (PropertyInfo propInfo in properties) { PropertyKey key = (PropertyKey)propInfo.GetValue(null); ShellPropertyDescription desc = SystemProperties.GetPropertyDescription(key); string canonicalName = desc.CanonicalName; if ((!canonicalNames.Contains(canonicalName)) && canonicalName != null) { canonicalNames.Add(canonicalName); } } } }
void DoAction(string[] args) { if (args.Length == 0 || args[0].Contains("?")) { Usage(); return; } if (args[0].Equals("-get", StringComparison.InvariantCultureIgnoreCase)) { if (args.Length != 3) { Usage(); return; } string propertyName = args[1]; string fileName = Path.GetFullPath(args[2]); IShellProperty prop = ShellObject.FromParsingName(fileName).Properties.GetProperty(propertyName); DisplayPropertyValue(prop); } else if (args[0].Equals("-set", StringComparison.InvariantCultureIgnoreCase)) { if (args.Length != 4) { Usage(); return; } string propertyName = args[1]; string value = args[2]; string fileName = Path.GetFullPath(args[3]); IShellProperty prop = ShellObject.FromParsingName(fileName).Properties.GetProperty(propertyName); SetPropertyValue(value, prop); } else if (args[0].Equals("-info", StringComparison.InvariantCultureIgnoreCase)) { //if (args.Length != 2) if (args.Length != 3) { Usage(); return; } string propertyName = args[1]; ShellPropertyDescription propDesc = SystemProperties.GetPropertyDescription(propertyName); ShowPropertyInfo(propertyName, propDesc); } else if (args[0].Equals("-enum", StringComparison.InvariantCultureIgnoreCase)) { if (args.Length < 2) { Usage(); return; } string fileName = null; string filter = null; if (args.Length > 2) { filter = args[1]; fileName = Path.GetFullPath(args[2]); } else { fileName = Path.GetFullPath(args[1]); } EnumProperties(fileName, filter); } else { Usage(); return; } }