diff --git a/PInvoke/Ole/PropSys/PropSys.Interfaces.cs b/PInvoke/Ole/PropSys/PropSys.Interfaces.cs new file mode 100644 index 00000000..8709278f --- /dev/null +++ b/PInvoke/Ole/PropSys/PropSys.Interfaces.cs @@ -0,0 +1,661 @@ +using System; +using System.Runtime.InteropServices; +using System.Runtime.InteropServices.ComTypes; +using System.Security; +using Vanara.InteropServices; +using static Vanara.PInvoke.Ole32; + +namespace Vanara.PInvoke +{ + public static partial class PropSys + { + /// Provides a set of flags to be used with following methods to indicate the operation in ICondition::GetComparisonInfo, ICondition2::GetLeafConditionInfo, IConditionFactory::MakeLeaf, IConditionFactory2::CreateBooleanLeaf, IConditionFactory2::CreateIntegerLeaf, IConditionFactory2::MakeLeaf, IConditionFactory2::CreateStringLeaf, and IConditionGenerator::GenerateForLeaf. + [PInvokeData("Propsys.h", MSDNShortId = "aa965691")] + public enum CONDITION_OPERATION + { + /// An implicit comparison between the value of the property and the value of the constant. For an unresolved condition, COP_IMPLICIT means that a user did not type an operation. In contrast, a resolved condition will always have a condition other than the COP_IMPLICIT operation. + COP_IMPLICIT = 0, + /// The value of the property and the value of the constant must be equal. + COP_EQUAL = 1, + /// The value of the property and the value of the constant must not be equal. + COP_NOTEQUAL = 2, + /// The value of the property must be less than the value of the constant. + COP_LESSTHAN = 3, + /// The value of the property must be greater than the value of the constant. + COP_GREATERTHAN = 4, + /// The value of the property must be less than or equal to the value of the constant. + COP_LESSTHANOREQUAL = 5, + /// The value of the property must be greater than or equal to the value of the constant. + COP_GREATERTHANOREQUAL = 6, + /// The value of the property must begin with the value of the constant. + COP_VALUE_STARTSWITH = 7, + /// The value of the property must end with the value of the constant. + COP_VALUE_ENDSWITH = 8, + /// The value of the property must contain the value of the constant. + COP_VALUE_CONTAINS = 9, + /// The value of the property must not contain the value of the constant. + COP_VALUE_NOTCONTAINS = 10, + /// The value of the property must match the value of the constant, where '?' matches any single character and '*' matches any sequence of characters. + COP_DOSWILDCARDS = 11, + /// The value of the property must contain a word that is the value of the constant. + COP_WORD_EQUAL = 12, + /// The value of the property must contain a word that begins with the value of the constant. + COP_WORD_STARTSWITH = 13, + /// The application is free to interpret this in any suitable way. + COP_APPLICATION_SPECIFIC = 14 + } + + /// Describes how property values are displayed when multiple items are selected. For a particular property, PROPDESC_AGGREGATION_TYPE describes how the property should be displayed when multiple items that have a value for the property are selected, such as whether the values should be summed, or averaged, or just displayed with the default "Multiple Values" string. + [PInvokeData("Propsys.h", MSDNShortId = "bb762522")] + public enum PROPDESC_AGGREGATION_TYPE + { + /// Display the string "Multiple Values". + PDAT_DEFAULT = 0, + /// Display the first value in the selection. + PDAT_FIRST = 1, + /// Display the sum of the selected values. This flag is never returned for data types VT_LPWSTR, VT_BOOL, and VT_FILETIME. + PDAT_SUM = 2, + /// Display the numerical average of the selected values. This flag is never returned for data types VT_LPWSTR, VT_BOOL, and VT_FILETIME. + PDAT_AVERAGE = 3, + /// Display the date range of the selected values. This flag is returned only for values of the VT_FILETIME data type. + PDAT_DATERANGE = 4, + /// Display a concatenated string of all the values. The order of individual values in the string is undefined. The concatenated string omits duplicate values; if a value occurs more than once, it appears only once in the concatenated string. + PDAT_UNION = 5, + /// Display the highest of the selected values. + PDAT_MAX = 6, + /// Display the lowest of the selected values. + PDAT_MIN = 7 + } + + /// Describes the condition type to use when displaying the property in the query builder UI in Windows Vista, but not in Windows 7 and later. + [PInvokeData("Propsys.h", MSDNShortId = "bb762523")] + public enum PROPDESC_CONDITION_TYPE + { + /// The default value; it means the condition type is unspecified. + PDCOT_NONE = 0, + /// Use the string condition type. + PDCOT_STRING = 1, + /// Use the size condition type. + PDCOT_SIZE = 2, + /// Use the date/time condition type. + PDCOT_DATETIME = 3, + /// Use the Boolean condition type. + PDCOT_BOOLEAN = 4, + /// Use the number condition type. + PDCOT_NUMBER = 5 + } + + /// A value that indicates the display type. + [PInvokeData("Propsys.h", MSDNShortId = "bb761535")] + public enum PROPDESC_DISPLAYTYPE + { + /// The value is displayed as a string. + PDDT_STRING = 0, + /// The value is displayed as an integer. + PDDT_NUMBER = 1, + /// The value is displayed as a Boolean value. + PDDT_BOOLEAN = 2, + /// The value is displayed as date and time. + PDDT_DATETIME = 3, + /// The value is displayed as an enumerated type-list. Use IPropertyDescription::GetEnumTypeList to handle this type. + PDDT_ENUMERATED = 4 + } + + /// Describes the filtered list of property descriptions that is returned. + public enum PROPDESC_ENUMFILTER + { + /// The list contains all property descriptions in the system. + PDEF_ALL = 0, // All properties in system + /// The list contains system property descriptions only. It excludes third-party property descriptions that are registered on the computer. + PDEF_SYSTEM = 1, // Only system properties + /// The list contains only third-party property descriptions that are registered on the computer. + PDEF_NONSYSTEM = 2, // Only non-system properties + /// The list contains only viewable properties, where <typeInfo isViewable="true">. + PDEF_VIEWABLE = 3, // Only viewable properties + /// Deprecated in Windows 7 and later. The list contains only queryable properties, where <typeInfo isViewable="true" isQueryable="true">. + PDEF_QUERYABLE = 4, // Deprecated + /// Deprecated in Windows 7 and later. The list contains only properties to be included in full-text queries. + PDEF_INFULLTEXTQUERY = 5, // Deprecated + /// The list contains only properties that are columns. + PDEF_COLUMN = 6, // Only properties that are columns + } + + /// Used by property description helper functions, such as PSFormatForDisplay, to indicate the format of a property string. + [PInvokeData("Propsys.h", MSDNShortId = "bb762525")] + [Flags] + public enum PROPDESC_FORMAT_FLAGS + { + /// Use the format settings specified in the property's .propdesc file. + PDFF_DEFAULT = 0, + /// Precede the value with the property's display name. If the hideLabelPrefix attribute of the labelInfo element in the property's .propinfo file is set to true, then this flag is ignored. + PDFF_PREFIXNAME = 0x1, + /// Treat the string as a file name. + PDFF_FILENAME = 0x2, + /// Byte sizes are always displayed in KB, regardless of size. This enables clean alignment of the values in the column. This flag applies only to properties that have been declared as type Integer in the displayType attribute of the displayInfo element in the property's .propinfo file. This flag overrides the numberFormat setting. + PDFF_ALWAYSKB = 0x4, + /// Reserved. + PDFF_RESERVED_RIGHTTOLEFT = 0x8, + /// Display time as "hh:mm am/pm". + PDFF_SHORTTIME = 0x10, + /// Display time as "hh:mm:ss am/pm". + PDFF_LONGTIME = 0x20, + /// Hide the time portion of datetime. + PDFF_HIDETIME = 0x40, + /// Display date as "MM/DD/YY". For example, "03/21/04". + PDFF_SHORTDATE = 0x80, + /// Display date as "DayOfWeek, Month day, year". For example, "Monday, March 21, 2009". + PDFF_LONGDATE = 0x100, + /// Hide the date portion of datetime. + PDFF_HIDEDATE = 0x200, + /// Use friendly date descriptions. For example, "Yesterday". + PDFF_RELATIVEDATE = 0x400, + /// Return the invitation text if formatting failed or the value was empty. Invitation text is text displayed in a text box as a cue for the user, such as "Enter your name". Formatting can fail if the data entered is not of an expected type, such as when alpha characters have been entered in a phone-number field. + PDFF_USEEDITINVITATION = 0x800, + /// If this flag is used, the PDFF_USEEDITINVITATION flag must also be specified. When the formatting flags are PDFF_READONLY | PDFF_USEEDITINVITATION and the algorithm would have shown invitation text, a string is returned that indicates the value is "Unknown" instead of returning the invitation text. + PDFF_READONLY = 0x1000, + /// Do not detect reading order automatically. Useful when converting to ANSI to omit the Unicode reading order characters. However, reading order characters for some values are still returned. + PDFF_NOAUTOREADINGORDER = 0x2000 + } + + /// A flag value that indicates the grouping type. + [PInvokeData("Propsys.h", MSDNShortId = "bb761542")] + public enum PROPDESC_GROUPING_RANGE + { + /// Displays individual values. + PDGR_DISCRETE = 0, + /// Displays static alphanumeric ranges. + PDGR_ALPHANUMERIC = 1, + /// Displays static size ranges. + PDGR_SIZE = 2, + /// Displays dynamically created ranges. + PDGR_DYNAMIC = 3, + /// Displays month and year groups. + PDGR_DATE = 4, + /// Displays percent groups. + PDGR_PERCENT = 5, + /// Displays percent groups returned by IPropertyDescription::GetEnumTypeList. + PDGR_ENUMERATED = 6 + } + + /// Describes the relative description type for a property description, as determined by the relativeDescriptionType attribute of the displayInfo element. + [PInvokeData("Propsys.h", MSDNShortId = "bb762526")] + public enum PROPDESC_RELATIVEDESCRIPTION_TYPE + { + /// General type. + PDRDT_GENERAL = 0, + /// Date type. + PDRDT_DATE = 1, + /// Size type. + PDRDT_SIZE = 2, + /// Count type. + PDRDT_COUNT = 3, + /// Revision type. + PDRDT_REVISION = 4, + /// Length type. + PDRDT_LENGTH = 5, + /// Duration type. + PDRDT_DURATION = 6, + /// Speed type. + PDRDT_SPEED = 7, + /// Rate type. + PDRDT_RATE = 8, + /// Rating type. + PDRDT_RATING = 9, + /// Priority type. + PDRDT_PRIORITY = 10 + } + + /// Indicate the sort types available to the user. + [PInvokeData("Propsys.h", MSDNShortId = "bb761551")] + public enum PROPDESC_SORTDESCRIPTION + { + /// Default. "Sort going up", "Sort going down" + PDSD_GENERAL = 0, + /// "A on top", "Z on top" + PDSD_A_Z = 1, + /// "Lowest on top", "Highest on top" + PDSD_LOWEST_HIGHEST = 2, + /// "Smallest on top", "Largest on top" + PDSD_SMALLEST_BIGGEST = 3, + /// "Oldest on top", "Newest on top" + PDSD_OLDEST_NEWEST = 4 + } + + /// Describes attributes of the typeInfo element in the property's .propdesc file. + [PInvokeData("Propsys.h", MSDNShortId = "bb762527")] + [Flags] + public enum PROPDESC_TYPE_FLAGS : uint + { + /// The property uses the default values for all attributes. + PDTF_DEFAULT = 0, + /// The property can have multiple values. These values are stored as a VT_VECTOR in the PROPVARIANT structure. This value is set by the multipleValues attribute of the typeInfo element in the property's .propdesc file. + PDTF_MULTIPLEVALUES = 0x1, + /// This flag indicates that a property is read-only, and cannot be written to. This value is set by the isInnate attribute of the typeInfo element in the property's .propdesc file. + PDTF_ISINNATE = 0x2, + /// The property is a group heading. This value is set by the isGroup attribute of the typeInfo element in the property's .propdesc file. + PDTF_ISGROUP = 0x4, + /// The user can group by this property. This value is set by the canGroupBy attribute of the typeInfo element in the property's .propdesc file. + PDTF_CANGROUPBY = 0x8, + /// The user can stack by this property. This value is set by the canStackBy attribute of the typeInfo element in the property's .propdesc file. + PDTF_CANSTACKBY = 0x10, + /// This property contains a hierarchy. This value is set by the isTreeProperty attribute of the typeInfo element in the property's .propdesc file. + PDTF_ISTREEPROPERTY = 0x20, + /// Deprecated in Windows 7 and later. Include this property in any full text query that is performed. This value is set by the includeInFullTextQuery attribute of the typeInfo element in the property's .propdesc file. + PDTF_INCLUDEINFULLTEXTQUERY = 0x40, + /// This property is meant to be viewed by the user. This influences whether the property shows up in the "Choose Columns" dialog box, for example. This value is set by the isViewable attribute of the typeInfo element in the property's .propdesc file. + PDTF_ISVIEWABLE = 0x80, + /// Deprecated in Windows 7 and later. This property is included in the list of properties that can be queried. A queryable property must also be viewable. This influences whether the property shows up in the query builder UI. This value is set by the isQueryable attribute of the typeInfo element in the property's .propdesc file. + PDTF_ISQUERYABLE = 0x100, + /// Windows Vista with Service Pack 1 (SP1) and later. Used with an innate property (that is, a value calculated from other property values) to indicate that it can be deleted. This value is used by the Remove Properties UI to determine whether to display a check box next to a property that enables that property to be selected for removal. Note that a property that is not innate can always be purged regardless of the presence or absence of this flag. + PDTF_CANBEPURGED = 0x200, + /// Windows 7 and later. The unformatted (raw) property value should be used for searching. + PDTF_SEARCHRAWVALUE = 0x400, + PDTF_DONTCOERCEEMPTYSTRINGS = 0x800, + PDTF_ALWAYSINSUPPLEMENTALSTORE = 0x1000, + /// This property is owned by the system. + PDTF_ISSYSTEMPROPERTY = 0x80000000, + /// A mask used to retrieve all flags. + PDTF_MASK_ALL = 0x80001fff + } + + /// These flags describe properties in property description list strings. + [PInvokeData("Propsys.h", MSDNShortId = "bb762528")] + [Flags] + public enum PROPDESC_VIEW_FLAGS + { + /// Show this property by default. + PDVF_DEFAULT = 0, + /// This property should be centered. + PDVF_CENTERALIGN = 0x1, + /// This property should be right aligned. + PDVF_RIGHTALIGN = 0x2, + /// Show this property as the beginning of the next collection of properties in the view. + PDVF_BEGINNEWGROUP = 0x4, + /// Fill the remainder of the view area with the content of this property. + PDVF_FILLAREA = 0x8, + /// Sort this property in reverse (descending) order. Applies to a property in a list of sorted properties. + PDVF_SORTDESCENDING = 0x10, + /// Show this property only if it is present. + PDVF_SHOWONLYIFPRESENT = 0x20, + /// This property should be shown by default in a view (where applicable). + PDVF_SHOWBYDEFAULT = 0x40, + /// This property should be shown by default in the primary column selection UI. + PDVF_SHOWINPRIMARYLIST = 0x80, + /// This property should be shown by default in the secondary column selection UI. + PDVF_SHOWINSECONDARYLIST = 0x100, + /// Hide the label of this property if the view normally shows the label. + PDVF_HIDELABEL = 0x200, + /// This property should not be displayed as a column in the UI. + PDVF_HIDDEN = 0x800, + /// This property can be wrapped to the next row. + PDVF_CANWRAP = 0x1000, + /// A mask used to retrieve all flags. + PDVF_MASK_ALL = 0x1bff + } + + /// Property Enumeration Types + public enum PROPENUMTYPE + { + /// Use DisplayText and either RangeMinValue or RangeSetValue. + PET_DISCRETEVALUE = 0, + + /// Use DisplayText and either RangeMinValue or RangeSetValue + PET_RANGEDVALUE = 1, + + /// Use DisplayText + PET_DEFAULTVALUE = 2, + + /// Use Value or RangeMinValue + PET_ENDRANGE = 3 + } + + /// Values used by . + [PInvokeData("propsys.h", MSDNShortId = "855c9f10-9f40-4c60-a669-551fa51133f5")] + public enum STOREID + { + /// Undocumented. + STOREID_INNATE = 0, + /// Undocumented. + STOREID_FILE = 1, + /// Undocumented. + STOREID_FALLBACK = 2 + } + + /// Exposes a method to create a specified IPropertyStore object in circumstances where property access is potentially slow. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nn-propsys-idelayedpropertystorefactory + [PInvokeData("propsys.h", MSDNShortId = "855c9f10-9f40-4c60-a669-551fa51133f5")] + [ComImport, Guid("40d4577f-e237-4bdb-bd69-58f089431b6a"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + public interface IDelayedPropertyStoreFactory : IPropertyStoreFactory + { + /// Gets an IPropertyStore interface object, as specified.Type: GETPROPERTYSTOREFLAGSThe GPS_XXX flags that modify the store that is returned. See GETPROPERTYSTOREFLAGS.Type: DWORDThe property store ID. Valid values are.STOREID_INNATEValue is 0.STOREID_FILEValue is 1.STOREID_FALLBACKValue is 2.Type: REFIIDA reference to the desired IID.Type: void**The address of an IPropertyStore interface pointer.Type: HRESULTIf this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-idelayedpropertystorefactory-getdelayedpropertystore + // HRESULT GetDelayedPropertyStore( GETPROPERTYSTOREFLAGS flags, DWORD dwStoreId, REFIID riid, void **ppv ); + void GetDelayedPropertyStore(GETPROPERTYSTOREFLAGS flags, STOREID dwStoreId, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IPropertyStore ppv); + } + + /// Exposes a method that initializes a handler, such as a property handler, thumbnail handler, or preview handler, with a stream. + [ComImport, Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [PInvokeData("Propsys.h", MSDNShortId = "bb761810")] + public interface IInitializeWithStream + { + /// Initializes a handler with a stream. + /// A pointer to an IStream interface that represents the stream source. + /// One of the following STGM values that indicates the access mode for pstream. STGM_READ or STGM_READWRITE. + void Initialize(IStream pstream, STGM grfMode); + } + + // Exposes methods that enumerate and retrieve individual property description details. + [ComImport, Guid("6F79D558-3E96-4549-A1D1-7D75D2288814"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [PInvokeData("Propsys.h", MSDNShortId = "bb761561")] + public interface IPropertyDescription + { + /// Gets a structure that acts as a property's unique identifier. + /// When this method returns, contains a pointer to a PROPERTYKEY structure. + PROPERTYKEY GetPropertyKey(); + /// Gets the case-sensitive name by which a property is known to the system, regardless of its localized name. + /// When this method returns, contains the address of a pointer to the property's canonical name as a null-terminated Unicode string. + SafeCoTaskMemString GetCanonicalName(); + /// Gets the variant type of the property. + /// When this method returns, contains a pointer to a VARTYPE that indicates the property type. If the property is multi-valued, the value pointed to is a VT_VECTOR mask (VT_VECTOR ORed to the VARTYPE. + VARTYPE GetPropertyType(); + /// Gets the display name of the property as it is shown in any UI. + /// Contains the address of a pointer to the property's name as a null-terminated Unicode string. + [PreserveSig] + HRESULT GetDisplayName(out SafeCoTaskMemString pszName); + /// Gets the text used in edit controls hosted in various dialog boxes. + /// When this method returns, contains the address of a pointer to a null-terminated Unicode buffer that holds the invitation text. + SafeCoTaskMemString GetEditInvitation(); + /// Gets a set of flags that describe the uses and capabilities of the property. + /// A mask that specifies which type flags to retrieve. A combination of values found in the PROPDESC_TYPE_FLAGS constants. To retrieve all type flags, pass PDTF_MASK_ALL + /// When this method returns, contains a pointer to a value that consists of bitwise PROPDESC_TYPE_FLAGS values. + PROPDESC_TYPE_FLAGS GetTypeFlags([In] PROPDESC_TYPE_FLAGS mask); + /// Gets the current set of flags governing the property's view. + /// When this method returns, contains a pointer to a value that includes one or more of the following flags. See PROPDESC_VIEW_FLAGS for valid values. + PROPDESC_VIEW_FLAGS GetViewFlags(); + /// Gets the default column width of the property in a list view. + /// A pointer to the column width value, in characters. + uint GetDefaultColumnWidth(); + /// Gets the current data type used to display the property. + /// Contains a pointer to a value that indicates the display type. + PROPDESC_DISPLAYTYPE GetDisplayType(); + /// Gets the column state flag, which describes how the property should be treated by interfaces or APIs that use this flag. + /// When this method returns, contains a pointer to the column state flag. + SHCOLSTATE GetColumnState(); + /// Gets the grouping method to be used when a view is grouped by a property, and retrieves the grouping type. + /// Receives a pointer to a flag value that indicates the grouping type. + PROPDESC_GROUPING_RANGE GetGroupingRange(); + /// Gets the relative description type for a property description. + /// When this method returns, contains a pointer to the relative description type value. See PROPDESC_RELATIVEDESCRIPTION_TYPE for valid values. + PROPDESC_RELATIVEDESCRIPTION_TYPE GetRelativeDescriptionType(); + /// Compares two property values in the manner specified by the property description. Returns two display strings that describe how the two properties compare. + /// A reference to a PROPVARIANT structure that contains the type and value of the first property. + /// A reference to a PROPVARIANT structure that contains the type and value of the second property. + /// When this method returns, contains the address of a pointer to the description string that compares the first property with the second property. The string is null-terminated. + /// When this method returns, contains the address of a pointer to the description string that compares the second property with the first property. The string is null-terminated. + void GetRelativeDescription([In] PROPVARIANT propvar1, [In] PROPVARIANT propvar2, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDesc1, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDesc2); + /// Gets the current sort description flags for the property, which indicate the particular wordings of sort offerings. + /// When this method returns, contains a pointer to the value of one or more of the following flags that indicate the sort types available to the user. Note that the strings shown are English versions only. Localized strings are used for other locales. + PROPDESC_SORTDESCRIPTION GetSortDescription(); + /// Gets the localized display string that describes the current sort order. + /// TRUE if ppszDescription should reference the string "Z on top"; FALSE to reference the string "A on top". + /// When this method returns, contains the address of a pointer to the sort description as a null-terminated Unicode string. + SafeCoTaskMemString GetSortDescriptionLabel([In, MarshalAs(UnmanagedType.Bool)] bool fDescending); + /// Gets a value that describes how the property values are displayed when multiple items are selected in the UI. + /// When this method returns, contains a pointer to a value that indicates the aggregation type. + PROPDESC_AGGREGATION_TYPE GetAggregationType(); + /// Gets the condition type and default condition operation to use when displaying the property in the query builder UI. This influences the list of predicate conditions (for example, equals, less than, and contains) that are shown for this property. + /// A pointer to a value that indicates the condition type. + /// When this method returns, contains a pointer to a value that indicates the default condition operation. + void GetConditionType(out PROPDESC_CONDITION_TYPE pcontype, out CONDITION_OPERATION popDefault); + /// Gets an instance of an IPropertyEnumTypeList, which can be used to enumerate the possible values for a property. + /// Reference to the interface ID of the requested interface. + /// When this method returns, contains the address of an IPropertyEnumTypeList interface pointer. + [return: MarshalAs(UnmanagedType.Interface)] + IPropertyEnumTypeList GetEnumTypeList([MarshalAs(UnmanagedType.LPStruct)] Guid riid); + /// Coerces the value to the canonical value, according to the property description. + /// On entry, contains a pointer to a PROPVARIANT structure that contains the original value. When this method returns, contains the canonical value. + [PreserveSig] + HRESULT CoerceToCanonicalValue([In, Out] PROPVARIANT propvar); + /// Gets a formatted, Unicode string representation of a property value. + /// A reference to a PROPVARIANT structure that contains the type and value of the property. + /// One or more of the PROPDESC_FORMAT_FLAGS flags, which are either bitwise or multiple values, that indicate the property string format. + /// When this method returns, contains the formatted value as a null-terminated, Unicode string. The calling application must allocate memory for the buffer, and use CoTaskMemFree to release the string specified by pszText when it is no longer needed. + SafeCoTaskMemString FormatForDisplay([In] PROPVARIANT propvar, [In] PROPDESC_FORMAT_FLAGS pdfFlags); + /// Gets a value that indicates whether a property is canonical according to the definition of the property description. + /// A reference to a PROPVARIANT structure that contains the type and value of the property. + /// Returns one of the following values: S_OK = The value is canonical; S_FALSE = The value is not canonical. + [PreserveSig] + HRESULT IsValueCanonical([In] PROPVARIANT propvar); + } + + [ComImport, Guid("57d2eded-5062-400e-b107-5dae79fe57a6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [PInvokeData("Propsys.h", MSDNShortId = "bb761561")] + public interface IPropertyDescription2 : IPropertyDescription + { + /// Gets a structure that acts as a property's unique identifier. + /// When this method returns, contains a pointer to a PROPERTYKEY structure. + new PROPERTYKEY GetPropertyKey(); + /// Gets the case-sensitive name by which a property is known to the system, regardless of its localized name. + /// When this method returns, contains the address of a pointer to the property's canonical name as a null-terminated Unicode string. + new SafeCoTaskMemString GetCanonicalName(); + /// Gets the variant type of the property. + /// When this method returns, contains a pointer to a VARTYPE that indicates the property type. If the property is multi-valued, the value pointed to is a VT_VECTOR mask (VT_VECTOR ORed to the VARTYPE. + new VARTYPE GetPropertyType(); + /// Gets the display name of the property as it is shown in any UI. + /// Contains the address of a pointer to the property's name as a null-terminated Unicode string. + [PreserveSig] + new HRESULT GetDisplayName(out SafeCoTaskMemString pszName); + /// Gets the text used in edit controls hosted in various dialog boxes. + /// When this method returns, contains the address of a pointer to a null-terminated Unicode buffer that holds the invitation text. + new SafeCoTaskMemString GetEditInvitation(); + /// Gets a set of flags that describe the uses and capabilities of the property. + /// A mask that specifies which type flags to retrieve. A combination of values found in the PROPDESC_TYPE_FLAGS constants. To retrieve all type flags, pass PDTF_MASK_ALL + /// When this method returns, contains a pointer to a value that consists of bitwise PROPDESC_TYPE_FLAGS values. + new PROPDESC_TYPE_FLAGS GetTypeFlags([In] PROPDESC_TYPE_FLAGS mask); + /// Gets the current set of flags governing the property's view. + /// When this method returns, contains a pointer to a value that includes one or more of the following flags. See PROPDESC_VIEW_FLAGS for valid values. + new PROPDESC_VIEW_FLAGS GetViewFlags(); + /// Gets the default column width of the property in a list view. + /// A pointer to the column width value, in characters. + new uint GetDefaultColumnWidth(); + /// Gets the current data type used to display the property. + /// Contains a pointer to a value that indicates the display type. + new PROPDESC_DISPLAYTYPE GetDisplayType(); + /// Gets the column state flag, which describes how the property should be treated by interfaces or APIs that use this flag. + /// When this method returns, contains a pointer to the column state flag. + new SHCOLSTATE GetColumnState(); + /// Gets the grouping method to be used when a view is grouped by a property, and retrieves the grouping type. + /// Receives a pointer to a flag value that indicates the grouping type. + new PROPDESC_GROUPING_RANGE GetGroupingRange(); + /// Gets the relative description type for a property description. + /// When this method returns, contains a pointer to the relative description type value. See PROPDESC_RELATIVEDESCRIPTION_TYPE for valid values. + new PROPDESC_RELATIVEDESCRIPTION_TYPE GetRelativeDescriptionType(); + /// Compares two property values in the manner specified by the property description. Returns two display strings that describe how the two properties compare. + /// A reference to a PROPVARIANT structure that contains the type and value of the first property. + /// A reference to a PROPVARIANT structure that contains the type and value of the second property. + /// When this method returns, contains the address of a pointer to the description string that compares the first property with the second property. The string is null-terminated. + /// When this method returns, contains the address of a pointer to the description string that compares the second property with the first property. The string is null-terminated. + new void GetRelativeDescription([In] PROPVARIANT propvar1, [In] PROPVARIANT propvar2, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDesc1, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDesc2); + /// Gets the current sort description flags for the property, which indicate the particular wordings of sort offerings. + /// When this method returns, contains a pointer to the value of one or more of the following flags that indicate the sort types available to the user. Note that the strings shown are English versions only. Localized strings are used for other locales. + new PROPDESC_SORTDESCRIPTION GetSortDescription(); + /// Gets the localized display string that describes the current sort order. + /// TRUE if ppszDescription should reference the string "Z on top"; FALSE to reference the string "A on top". + /// When this method returns, contains the address of a pointer to the sort description as a null-terminated Unicode string. + new SafeCoTaskMemString GetSortDescriptionLabel([In, MarshalAs(UnmanagedType.Bool)] bool fDescending); + /// Gets a value that describes how the property values are displayed when multiple items are selected in the UI. + /// When this method returns, contains a pointer to a value that indicates the aggregation type. + new PROPDESC_AGGREGATION_TYPE GetAggregationType(); + /// Gets the condition type and default condition operation to use when displaying the property in the query builder UI. This influences the list of predicate conditions (for example, equals, less than, and contains) that are shown for this property. + /// A pointer to a value that indicates the condition type. + /// When this method returns, contains a pointer to a value that indicates the default condition operation. + new void GetConditionType(out PROPDESC_CONDITION_TYPE pcontype, out CONDITION_OPERATION popDefault); + /// Gets an instance of an IPropertyEnumTypeList, which can be used to enumerate the possible values for a property. + /// Reference to the interface ID of the requested interface. + /// When this method returns, contains the address of an IPropertyEnumTypeList interface pointer. + [return: MarshalAs(UnmanagedType.Interface)] + new IPropertyEnumTypeList GetEnumTypeList([MarshalAs(UnmanagedType.LPStruct)] Guid riid); + /// Coerces the value to the canonical value, according to the property description. + /// On entry, contains a pointer to a PROPVARIANT structure that contains the original value. When this method returns, contains the canonical value. + [PreserveSig] + new HRESULT CoerceToCanonicalValue([In, Out] PROPVARIANT propvar); + /// Gets a formatted, Unicode string representation of a property value. + /// A reference to a PROPVARIANT structure that contains the type and value of the property. + /// One or more of the PROPDESC_FORMAT_FLAGS flags, which are either bitwise or multiple values, that indicate the property string format. + /// When this method returns, contains the formatted value as a null-terminated, Unicode string. The calling application must allocate memory for the buffer, and use CoTaskMemFree to release the string specified by pszText when it is no longer needed. + new SafeCoTaskMemString FormatForDisplay([In] PROPVARIANT propvar, [In] PROPDESC_FORMAT_FLAGS pdfFlags); + /// Gets a value that indicates whether a property is canonical according to the definition of the property description. + /// A reference to a PROPVARIANT structure that contains the type and value of the property. + /// Returns one of the following values: S_OK = The value is canonical; S_FALSE = The value is not canonical. + [PreserveSig] + new HRESULT IsValueCanonical([In] PROPVARIANT propvar); + /// Gets the image reference associated with a property value. + /// The PROPVARIANT for which to get an image. + /// A string that receives, when this method returns successfully, a string of the form <dll name>,-<resid> that is suitable to be passed to PathParseIconLocation. + /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + [PreserveSig] + HRESULT GetImageReferenceForValue([In] PROPVARIANT propvar, out SafeCoTaskMemString ppszImageRes); + } + + [ComImport, Guid("1F9FC1D0-C39B-4B26-817F-011967D3440E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [PInvokeData("Propsys.h", MSDNShortId = "bb761511")] + public interface IPropertyDescriptionList + { + uint GetCount(); + IPropertyDescription GetAt([In] uint iElem, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + } + + /// + /// Exposes methods that extract data from enumeration information. IPropertyEnumType gives access to the enum and enumRange elements in the property + /// schema in a programmatic way at run time. + /// + [ComImport, Guid("11e1fbf9-2d56-4a6b-8db3-7cd193a471f2"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [PInvokeData("Propsys.h")] + public interface IPropertyEnumType + { + /// Gets an enumeration type from an enumeration information structure. + /// When this method returns, contains a value that indicate the enumeration type. + PROPENUMTYPE GetEnumType(); + /// Gets a value from an enumeration information structure. + /// When this method returns, contains a pointer to the property value. + void GetValue([Out] PROPVARIANT ppropvar); + /// Gets a minimum value from an enumeration information structure. + /// When this method returns, contains a pointer to the minimum value. + void GetRangeMinValue([Out] PROPVARIANT ppropvarMin); + /// Gets a set value from an enumeration information structure. + /// When this method returns, contains a pointer to the set value. + void GetRangeSetValue([Out] PROPVARIANT ppropvarSet); + /// Gets display text from an enumeration information structure. + /// When this method returns, contains the address of a pointer to a null-terminated Unicode string that contains the display text. + void GetDisplayText([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszDisplay); + } + + /// Exposes methods that extract data from enumeration information. IPropertyEnumType2 extends IPropertyEnumType. + /// + [ComImport, Guid("9b6e051c-5ddd-4321-9070-fe2acb55e794"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [PInvokeData("Propsys.h")] + public interface IPropertyEnumType2 : IPropertyEnumType + { + /// Gets an enumeration type from an enumeration information structure. + /// When this method returns, contains a value that indicate the enumeration type. + new PROPENUMTYPE GetEnumType(); + /// Gets a value from an enumeration information structure. + /// When this method returns, contains a pointer to the property value. + new void GetValue([Out] PROPVARIANT ppropvar); + /// Gets a minimum value from an enumeration information structure. + /// When this method returns, contains a pointer to the minimum value. + new void GetRangeMinValue([Out] PROPVARIANT ppropvarMin); + /// Gets a set value from an enumeration information structure. + /// When this method returns, contains a pointer to the set value. + new void GetRangeSetValue([Out] PROPVARIANT ppropvarSet); + /// Gets display text from an enumeration information structure. + /// When this method returns, contains the address of a pointer to a null-terminated Unicode string that contains the display text. + new void GetDisplayText([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszDisplay); + /// Retrieves the image reference associated with a property enumeration. + /// A pointer to a buffer that, when this method returns successfully, receives a string of the form <dll name>,-<resid> that is suitable to be passed to PathParseIconLocation. + [PreserveSig] HRESULT GetImageReference([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszImageRes); + } + + [ComImport, Guid("A99400F4-3D84-4557-94BA-1242FB2CC9A6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] + [PInvokeData("Propsys.h")] + public interface IPropertyEnumTypeList + { + uint GetCount(); + + [return: MarshalAs(UnmanagedType.Interface)] + IPropertyEnumType GetAt([In] uint itype, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + + [return: MarshalAs(UnmanagedType.Interface)] + object GetConditionAt([In] uint index, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + + /// Compares the specified property value against the enumerated values in a list and returns the matching index. + /// A reference to a PROPVARIANT structure that represents the property value. + /// When this method returns, contains a pointer to the index in the enumerated type list that matches the property value, if any. + /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + [PreserveSig] + HRESULT FindMatchingIndex([In] PROPVARIANT propvarCmp, out uint pnIndex); + } + + [SuppressUnmanagedCodeSecurity] + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99")] + [PInvokeData("Shobjidl.h", MSDNShortId = "bb762502")] + public interface IPropertyStore + { + uint GetCount(); + + PROPERTYKEY GetAt(uint iProp); + + void GetValue([In] ref PROPERTYKEY pkey, [In, Out] PROPVARIANT pv); + + void SetValue([In] ref PROPERTYKEY pkey, [In] PROPVARIANT pv); + + void Commit(); + } + + /// Exposes methods to get an IPropertyStore object.This interface is typically obtained through IShellFolder::BindToObject or IShellItem::BindToHandler. It is useful for data source implementers who want to avoid the additional overhead of creating a property store through IShellItem2::GetPropertyStore. However, IShellItem2::GetPropertyStore is the recommended method to obtain a property store unless you are implementing a data source through a Shell folder extension. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nn-propsys-ipropertystorefactory + [PInvokeData("propsys.h", MSDNShortId = "78ea822d-da8e-4883-b0eb-4277e7eb87a2")] + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("bc110b6d-57e8-4148-a9c6-91015ab2f3a5")] + public interface IPropertyStoreFactory + { + /// Gets an IPropertyStore object that corresponds to the supplied flags.Type: GETPROPERTYSTOREFLAGSGETPROPERTYSTOREFLAGS values that modify the store that is returned.Type: IUnknown*Optional. A pointer to the IUnknown of an object that implements ICreateObject. If pUnkFactory is provided, this method can create the handler instance using ICreateObject rather than CoCreateInstance, if implemented. The reason to provide pUnkFactory is usually to create the handler in a different process. However, for most users, passing NULL in this parameter is sufficient.Type: REFIIDA reference to IID of the object to create.Type: void**When this method returns, contains the address of an IPropertyStore interface pointer.Type: HRESULTIf this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.It is recommended that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding error. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-ipropertystorefactory-getpropertystore + // HRESULT GetPropertyStore( GETPROPERTYSTOREFLAGS flags, IUnknown *pUnkFactory, REFIID riid, void **ppv ); + void GetPropertyStore(GETPROPERTYSTOREFLAGS flags, [MarshalAs(UnmanagedType.IUnknown)] object pUnkFactory, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IPropertyStore ppv); + + /// Gets an IPropertyStore object, given a set of property keys. This provides an alternative, possibly faster, method of getting an IPropertyStore object compared to calling IPropertyStoreFactory::GetPropertyStore.Type: const PROPERTYKEY*A pointer to an array of PROPERTYKEY structures.Type: UINTThe number of PROPERTYKEY structures in the array pointed to by rgKeys.Type: GETPROPERTYSTOREFLAGSGETPROPERTYSTOREFLAGS values that modify the store that is returned.Type: REFIIDA reference to IID of the object to create.Type: void**When this method returns, contains the address of an IPropertyStore interface pointer.Type: HRESULTIf this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.It is recommended that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding error. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-ipropertystorefactory-getpropertystoreforkeys + // HRESULT GetPropertyStoreForKeys( const PROPERTYKEY *rgKeys, UINT cKeys, GETPROPERTYSTOREFLAGS flags, REFIID riid, void **ppv ); + void GetPropertyStoreForKeys([In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 1)] PROPERTYKEY[] rgKeys, uint cKeys, GETPROPERTYSTOREFLAGS flags, + [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, out IPropertyStore ppv); + } + + [SuppressUnmanagedCodeSecurity] + [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("ca724e8a-c3e6-442b-88a4-6fb0db8035a3")] + [PInvokeData("PropSys.h")] + public interface IPropertySystem + { + [return: MarshalAs(UnmanagedType.Interface)] + IPropertyDescription GetPropertyDescription(ref PROPERTYKEY propkey, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + + [return: MarshalAs(UnmanagedType.Interface)] + IPropertyDescription GetPropertyDescriptionByName([In, MarshalAs(UnmanagedType.LPWStr)] string pszCanonicalName, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + + [return: MarshalAs(UnmanagedType.Interface)] + IPropertyDescriptionList GetPropertyDescriptionListFromString([In, MarshalAs(UnmanagedType.LPWStr)] string pszPropList, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + + [return: MarshalAs(UnmanagedType.Interface)] + IPropertyDescriptionList EnumeratePropertyDescriptions(PROPDESC_ENUMFILTER filterOn, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); + + void FormatForDisplay(ref PROPERTYKEY key, PROPVARIANT propvar, PROPDESC_FORMAT_FLAGS pdff, System.Text.StringBuilder pszText, uint cchText); + + SafeCoTaskMemString FormatForDisplayAlloc(ref PROPERTYKEY key, PROPVARIANT propvar, PROPDESC_FORMAT_FLAGS pdff); + + void RegisterPropertySchema([In, MarshalAs(UnmanagedType.LPWStr)] string pszPath); + + void UnregisterPropertySchema([In, MarshalAs(UnmanagedType.LPWStr)] string pszPath); + + void RefreshPropertySchema(); + } + } +} diff --git a/PInvoke/Ole/PropSys/PropSys.cs b/PInvoke/Ole/PropSys/PropSys.cs index 4c1a83e9..b8e7b0e3 100644 --- a/PInvoke/Ole/PropSys/PropSys.cs +++ b/PInvoke/Ole/PropSys/PropSys.cs @@ -1,8 +1,6 @@ using System; -using System.Runtime.CompilerServices; using System.Runtime.InteropServices; -using System.Runtime.InteropServices.ComTypes; -using System.Security; +using System.Text; using Vanara.InteropServices; using static Vanara.PInvoke.Ole32; @@ -10,42 +8,6 @@ namespace Vanara.PInvoke { public static partial class PropSys { - /// Provides a set of flags to be used with following methods to indicate the operation in ICondition::GetComparisonInfo, ICondition2::GetLeafConditionInfo, IConditionFactory::MakeLeaf, IConditionFactory2::CreateBooleanLeaf, IConditionFactory2::CreateIntegerLeaf, IConditionFactory2::MakeLeaf, IConditionFactory2::CreateStringLeaf, and IConditionGenerator::GenerateForLeaf. - [PInvokeData("Propsys.h", MSDNShortId = "aa965691")] - public enum CONDITION_OPERATION - { - /// An implicit comparison between the value of the property and the value of the constant. For an unresolved condition, COP_IMPLICIT means that a user did not type an operation. In contrast, a resolved condition will always have a condition other than the COP_IMPLICIT operation. - COP_IMPLICIT = 0, - /// The value of the property and the value of the constant must be equal. - COP_EQUAL = 1, - /// The value of the property and the value of the constant must not be equal. - COP_NOTEQUAL = 2, - /// The value of the property must be less than the value of the constant. - COP_LESSTHAN = 3, - /// The value of the property must be greater than the value of the constant. - COP_GREATERTHAN = 4, - /// The value of the property must be less than or equal to the value of the constant. - COP_LESSTHANOREQUAL = 5, - /// The value of the property must be greater than or equal to the value of the constant. - COP_GREATERTHANOREQUAL = 6, - /// The value of the property must begin with the value of the constant. - COP_VALUE_STARTSWITH = 7, - /// The value of the property must end with the value of the constant. - COP_VALUE_ENDSWITH = 8, - /// The value of the property must contain the value of the constant. - COP_VALUE_CONTAINS = 9, - /// The value of the property must not contain the value of the constant. - COP_VALUE_NOTCONTAINS = 10, - /// The value of the property must match the value of the constant, where '?' matches any single character and '*' matches any sequence of characters. - COP_DOSWILDCARDS = 11, - /// The value of the property must contain a word that is the value of the constant. - COP_WORD_EQUAL = 12, - /// The value of the property must contain a word that begins with the value of the constant. - COP_WORD_STARTSWITH = 13, - /// The application is free to interpret this in any suitable way. - COP_APPLICATION_SPECIFIC = 14 - } - /// /// /// Indicates flags that modify the property store object retrieved by methods that create a property store, such as @@ -179,577 +141,6 @@ namespace Vanara.PInvoke GPS_VOLATILEPROPERTIESONLY = 0x1000, } - /// Describes how property values are displayed when multiple items are selected. For a particular property, PROPDESC_AGGREGATION_TYPE describes how the property should be displayed when multiple items that have a value for the property are selected, such as whether the values should be summed, or averaged, or just displayed with the default "Multiple Values" string. - [PInvokeData("Propsys.h", MSDNShortId = "bb762522")] - public enum PROPDESC_AGGREGATION_TYPE - { - /// Display the string "Multiple Values". - PDAT_DEFAULT = 0, - /// Display the first value in the selection. - PDAT_FIRST = 1, - /// Display the sum of the selected values. This flag is never returned for data types VT_LPWSTR, VT_BOOL, and VT_FILETIME. - PDAT_SUM = 2, - /// Display the numerical average of the selected values. This flag is never returned for data types VT_LPWSTR, VT_BOOL, and VT_FILETIME. - PDAT_AVERAGE = 3, - /// Display the date range of the selected values. This flag is returned only for values of the VT_FILETIME data type. - PDAT_DATERANGE = 4, - /// Display a concatenated string of all the values. The order of individual values in the string is undefined. The concatenated string omits duplicate values; if a value occurs more than once, it appears only once in the concatenated string. - PDAT_UNION = 5, - /// Display the highest of the selected values. - PDAT_MAX = 6, - /// Display the lowest of the selected values. - PDAT_MIN = 7 - } - - /// Describes the condition type to use when displaying the property in the query builder UI in Windows Vista, but not in Windows 7 and later. - [PInvokeData("Propsys.h", MSDNShortId = "bb762523")] - public enum PROPDESC_CONDITION_TYPE - { - /// The default value; it means the condition type is unspecified. - PDCOT_NONE = 0, - /// Use the string condition type. - PDCOT_STRING = 1, - /// Use the size condition type. - PDCOT_SIZE = 2, - /// Use the date/time condition type. - PDCOT_DATETIME = 3, - /// Use the Boolean condition type. - PDCOT_BOOLEAN = 4, - /// Use the number condition type. - PDCOT_NUMBER = 5 - } - - /// A value that indicates the display type. - [PInvokeData("Propsys.h", MSDNShortId = "bb761535")] - public enum PROPDESC_DISPLAYTYPE - { - /// The value is displayed as a string. - PDDT_STRING = 0, - /// The value is displayed as an integer. - PDDT_NUMBER = 1, - /// The value is displayed as a Boolean value. - PDDT_BOOLEAN = 2, - /// The value is displayed as date and time. - PDDT_DATETIME = 3, - /// The value is displayed as an enumerated type-list. Use IPropertyDescription::GetEnumTypeList to handle this type. - PDDT_ENUMERATED = 4 - } - - /// Describes the filtered list of property descriptions that is returned. - public enum PROPDESC_ENUMFILTER - { - /// The list contains all property descriptions in the system. - PDEF_ALL = 0, // All properties in system - /// The list contains system property descriptions only. It excludes third-party property descriptions that are registered on the computer. - PDEF_SYSTEM = 1, // Only system properties - /// The list contains only third-party property descriptions that are registered on the computer. - PDEF_NONSYSTEM = 2, // Only non-system properties - /// The list contains only viewable properties, where <typeInfo isViewable="true">. - PDEF_VIEWABLE = 3, // Only viewable properties - /// Deprecated in Windows 7 and later. The list contains only queryable properties, where <typeInfo isViewable="true" isQueryable="true">. - PDEF_QUERYABLE = 4, // Deprecated - /// Deprecated in Windows 7 and later. The list contains only properties to be included in full-text queries. - PDEF_INFULLTEXTQUERY = 5, // Deprecated - /// The list contains only properties that are columns. - PDEF_COLUMN = 6, // Only properties that are columns - } - - /// Used by property description helper functions, such as PSFormatForDisplay, to indicate the format of a property string. - [PInvokeData("Propsys.h", MSDNShortId = "bb762525")] - [Flags] - public enum PROPDESC_FORMAT_FLAGS - { - /// Use the format settings specified in the property's .propdesc file. - PDFF_DEFAULT = 0, - /// Precede the value with the property's display name. If the hideLabelPrefix attribute of the labelInfo element in the property's .propinfo file is set to true, then this flag is ignored. - PDFF_PREFIXNAME = 0x1, - /// Treat the string as a file name. - PDFF_FILENAME = 0x2, - /// Byte sizes are always displayed in KB, regardless of size. This enables clean alignment of the values in the column. This flag applies only to properties that have been declared as type Integer in the displayType attribute of the displayInfo element in the property's .propinfo file. This flag overrides the numberFormat setting. - PDFF_ALWAYSKB = 0x4, - /// Reserved. - PDFF_RESERVED_RIGHTTOLEFT = 0x8, - /// Display time as "hh:mm am/pm". - PDFF_SHORTTIME = 0x10, - /// Display time as "hh:mm:ss am/pm". - PDFF_LONGTIME = 0x20, - /// Hide the time portion of datetime. - PDFF_HIDETIME = 0x40, - /// Display date as "MM/DD/YY". For example, "03/21/04". - PDFF_SHORTDATE = 0x80, - /// Display date as "DayOfWeek, Month day, year". For example, "Monday, March 21, 2009". - PDFF_LONGDATE = 0x100, - /// Hide the date portion of datetime. - PDFF_HIDEDATE = 0x200, - /// Use friendly date descriptions. For example, "Yesterday". - PDFF_RELATIVEDATE = 0x400, - /// Return the invitation text if formatting failed or the value was empty. Invitation text is text displayed in a text box as a cue for the user, such as "Enter your name". Formatting can fail if the data entered is not of an expected type, such as when alpha characters have been entered in a phone-number field. - PDFF_USEEDITINVITATION = 0x800, - /// If this flag is used, the PDFF_USEEDITINVITATION flag must also be specified. When the formatting flags are PDFF_READONLY | PDFF_USEEDITINVITATION and the algorithm would have shown invitation text, a string is returned that indicates the value is "Unknown" instead of returning the invitation text. - PDFF_READONLY = 0x1000, - /// Do not detect reading order automatically. Useful when converting to ANSI to omit the Unicode reading order characters. However, reading order characters for some values are still returned. - PDFF_NOAUTOREADINGORDER = 0x2000 - } - - /// A flag value that indicates the grouping type. - [PInvokeData("Propsys.h", MSDNShortId = "bb761542")] - public enum PROPDESC_GROUPING_RANGE - { - /// Displays individual values. - PDGR_DISCRETE = 0, - /// Displays static alphanumeric ranges. - PDGR_ALPHANUMERIC = 1, - /// Displays static size ranges. - PDGR_SIZE = 2, - /// Displays dynamically created ranges. - PDGR_DYNAMIC = 3, - /// Displays month and year groups. - PDGR_DATE = 4, - /// Displays percent groups. - PDGR_PERCENT = 5, - /// Displays percent groups returned by IPropertyDescription::GetEnumTypeList. - PDGR_ENUMERATED = 6 - } - - /// Describes the relative description type for a property description, as determined by the relativeDescriptionType attribute of the displayInfo element. - [PInvokeData("Propsys.h", MSDNShortId = "bb762526")] - public enum PROPDESC_RELATIVEDESCRIPTION_TYPE - { - /// General type. - PDRDT_GENERAL = 0, - /// Date type. - PDRDT_DATE = 1, - /// Size type. - PDRDT_SIZE = 2, - /// Count type. - PDRDT_COUNT = 3, - /// Revision type. - PDRDT_REVISION = 4, - /// Length type. - PDRDT_LENGTH = 5, - /// Duration type. - PDRDT_DURATION = 6, - /// Speed type. - PDRDT_SPEED = 7, - /// Rate type. - PDRDT_RATE = 8, - /// Rating type. - PDRDT_RATING = 9, - /// Priority type. - PDRDT_PRIORITY = 10 - } - - /// Indicate the sort types available to the user. - [PInvokeData("Propsys.h", MSDNShortId = "bb761551")] - public enum PROPDESC_SORTDESCRIPTION - { - /// Default. "Sort going up", "Sort going down" - PDSD_GENERAL = 0, - /// "A on top", "Z on top" - PDSD_A_Z = 1, - /// "Lowest on top", "Highest on top" - PDSD_LOWEST_HIGHEST = 2, - /// "Smallest on top", "Largest on top" - PDSD_SMALLEST_BIGGEST = 3, - /// "Oldest on top", "Newest on top" - PDSD_OLDEST_NEWEST = 4 - } - - /// Describes attributes of the typeInfo element in the property's .propdesc file. - [PInvokeData("Propsys.h", MSDNShortId = "bb762527")] - [Flags] - public enum PROPDESC_TYPE_FLAGS : uint - { - /// The property uses the default values for all attributes. - PDTF_DEFAULT = 0, - /// The property can have multiple values. These values are stored as a VT_VECTOR in the PROPVARIANT structure. This value is set by the multipleValues attribute of the typeInfo element in the property's .propdesc file. - PDTF_MULTIPLEVALUES = 0x1, - /// This flag indicates that a property is read-only, and cannot be written to. This value is set by the isInnate attribute of the typeInfo element in the property's .propdesc file. - PDTF_ISINNATE = 0x2, - /// The property is a group heading. This value is set by the isGroup attribute of the typeInfo element in the property's .propdesc file. - PDTF_ISGROUP = 0x4, - /// The user can group by this property. This value is set by the canGroupBy attribute of the typeInfo element in the property's .propdesc file. - PDTF_CANGROUPBY = 0x8, - /// The user can stack by this property. This value is set by the canStackBy attribute of the typeInfo element in the property's .propdesc file. - PDTF_CANSTACKBY = 0x10, - /// This property contains a hierarchy. This value is set by the isTreeProperty attribute of the typeInfo element in the property's .propdesc file. - PDTF_ISTREEPROPERTY = 0x20, - /// Deprecated in Windows 7 and later. Include this property in any full text query that is performed. This value is set by the includeInFullTextQuery attribute of the typeInfo element in the property's .propdesc file. - PDTF_INCLUDEINFULLTEXTQUERY = 0x40, - /// This property is meant to be viewed by the user. This influences whether the property shows up in the "Choose Columns" dialog box, for example. This value is set by the isViewable attribute of the typeInfo element in the property's .propdesc file. - PDTF_ISVIEWABLE = 0x80, - /// Deprecated in Windows 7 and later. This property is included in the list of properties that can be queried. A queryable property must also be viewable. This influences whether the property shows up in the query builder UI. This value is set by the isQueryable attribute of the typeInfo element in the property's .propdesc file. - PDTF_ISQUERYABLE = 0x100, - /// Windows Vista with Service Pack 1 (SP1) and later. Used with an innate property (that is, a value calculated from other property values) to indicate that it can be deleted. This value is used by the Remove Properties UI to determine whether to display a check box next to a property that enables that property to be selected for removal. Note that a property that is not innate can always be purged regardless of the presence or absence of this flag. - PDTF_CANBEPURGED = 0x200, - /// Windows 7 and later. The unformatted (raw) property value should be used for searching. - PDTF_SEARCHRAWVALUE = 0x400, - PDTF_DONTCOERCEEMPTYSTRINGS = 0x800, - PDTF_ALWAYSINSUPPLEMENTALSTORE = 0x1000, - /// This property is owned by the system. - PDTF_ISSYSTEMPROPERTY = 0x80000000, - /// A mask used to retrieve all flags. - PDTF_MASK_ALL = 0x80001fff - } - - /// These flags describe properties in property description list strings. - [PInvokeData("Propsys.h", MSDNShortId = "bb762528")] - [Flags] - public enum PROPDESC_VIEW_FLAGS - { - /// Show this property by default. - PDVF_DEFAULT = 0, - /// This property should be centered. - PDVF_CENTERALIGN = 0x1, - /// This property should be right aligned. - PDVF_RIGHTALIGN = 0x2, - /// Show this property as the beginning of the next collection of properties in the view. - PDVF_BEGINNEWGROUP = 0x4, - /// Fill the remainder of the view area with the content of this property. - PDVF_FILLAREA = 0x8, - /// Sort this property in reverse (descending) order. Applies to a property in a list of sorted properties. - PDVF_SORTDESCENDING = 0x10, - /// Show this property only if it is present. - PDVF_SHOWONLYIFPRESENT = 0x20, - /// This property should be shown by default in a view (where applicable). - PDVF_SHOWBYDEFAULT = 0x40, - /// This property should be shown by default in the primary column selection UI. - PDVF_SHOWINPRIMARYLIST = 0x80, - /// This property should be shown by default in the secondary column selection UI. - PDVF_SHOWINSECONDARYLIST = 0x100, - /// Hide the label of this property if the view normally shows the label. - PDVF_HIDELABEL = 0x200, - /// This property should not be displayed as a column in the UI. - PDVF_HIDDEN = 0x800, - /// This property can be wrapped to the next row. - PDVF_CANWRAP = 0x1000, - /// A mask used to retrieve all flags. - PDVF_MASK_ALL = 0x1bff - } - - /// Property Enumeration Types - public enum PROPENUMTYPE - { - /// Use DisplayText and either RangeMinValue or RangeSetValue. - PET_DISCRETEVALUE = 0, - - /// Use DisplayText and either RangeMinValue or RangeSetValue - PET_RANGEDVALUE = 1, - - /// Use DisplayText - PET_DEFAULTVALUE = 2, - - /// Use Value or RangeMinValue - PET_ENDRANGE = 3 - } - - /// Exposes a method that initializes a handler, such as a property handler, thumbnail handler, or preview handler, with a stream. - [ComImport, Guid("b824b49d-22ac-4161-ac8a-9916e8fa3f7f"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [PInvokeData("Propsys.h", MSDNShortId = "bb761810")] - public interface IInitializeWithStream - { - /// Initializes a handler with a stream. - /// A pointer to an IStream interface that represents the stream source. - /// One of the following STGM values that indicates the access mode for pstream. STGM_READ or STGM_READWRITE. - void Initialize(IStream pstream, STGM grfMode); - } - - // Exposes methods that enumerate and retrieve individual property description details. - [ComImport, Guid("6F79D558-3E96-4549-A1D1-7D75D2288814"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [PInvokeData("Propsys.h", MSDNShortId = "bb761561")] - public interface IPropertyDescription - { - /// Gets a structure that acts as a property's unique identifier. - /// When this method returns, contains a pointer to a PROPERTYKEY structure. - PROPERTYKEY GetPropertyKey(); - /// Gets the case-sensitive name by which a property is known to the system, regardless of its localized name. - /// When this method returns, contains the address of a pointer to the property's canonical name as a null-terminated Unicode string. - SafeCoTaskMemString GetCanonicalName(); - /// Gets the variant type of the property. - /// When this method returns, contains a pointer to a VARTYPE that indicates the property type. If the property is multi-valued, the value pointed to is a VT_VECTOR mask (VT_VECTOR ORed to the VARTYPE. - VARTYPE GetPropertyType(); - /// Gets the display name of the property as it is shown in any UI. - /// Contains the address of a pointer to the property's name as a null-terminated Unicode string. - [PreserveSig] - HRESULT GetDisplayName(out SafeCoTaskMemString pszName); - /// Gets the text used in edit controls hosted in various dialog boxes. - /// When this method returns, contains the address of a pointer to a null-terminated Unicode buffer that holds the invitation text. - SafeCoTaskMemString GetEditInvitation(); - /// Gets a set of flags that describe the uses and capabilities of the property. - /// A mask that specifies which type flags to retrieve. A combination of values found in the PROPDESC_TYPE_FLAGS constants. To retrieve all type flags, pass PDTF_MASK_ALL - /// When this method returns, contains a pointer to a value that consists of bitwise PROPDESC_TYPE_FLAGS values. - PROPDESC_TYPE_FLAGS GetTypeFlags([In] PROPDESC_TYPE_FLAGS mask); - /// Gets the current set of flags governing the property's view. - /// When this method returns, contains a pointer to a value that includes one or more of the following flags. See PROPDESC_VIEW_FLAGS for valid values. - PROPDESC_VIEW_FLAGS GetViewFlags(); - /// Gets the default column width of the property in a list view. - /// A pointer to the column width value, in characters. - uint GetDefaultColumnWidth(); - /// Gets the current data type used to display the property. - /// Contains a pointer to a value that indicates the display type. - PROPDESC_DISPLAYTYPE GetDisplayType(); - /// Gets the column state flag, which describes how the property should be treated by interfaces or APIs that use this flag. - /// When this method returns, contains a pointer to the column state flag. - SHCOLSTATE GetColumnState(); - /// Gets the grouping method to be used when a view is grouped by a property, and retrieves the grouping type. - /// Receives a pointer to a flag value that indicates the grouping type. - PROPDESC_GROUPING_RANGE GetGroupingRange(); - /// Gets the relative description type for a property description. - /// When this method returns, contains a pointer to the relative description type value. See PROPDESC_RELATIVEDESCRIPTION_TYPE for valid values. - PROPDESC_RELATIVEDESCRIPTION_TYPE GetRelativeDescriptionType(); - /// Compares two property values in the manner specified by the property description. Returns two display strings that describe how the two properties compare. - /// A reference to a PROPVARIANT structure that contains the type and value of the first property. - /// A reference to a PROPVARIANT structure that contains the type and value of the second property. - /// When this method returns, contains the address of a pointer to the description string that compares the first property with the second property. The string is null-terminated. - /// When this method returns, contains the address of a pointer to the description string that compares the second property with the first property. The string is null-terminated. - void GetRelativeDescription([In] PROPVARIANT propvar1, [In] PROPVARIANT propvar2, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDesc1, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDesc2); - /// Gets the current sort description flags for the property, which indicate the particular wordings of sort offerings. - /// When this method returns, contains a pointer to the value of one or more of the following flags that indicate the sort types available to the user. Note that the strings shown are English versions only. Localized strings are used for other locales. - PROPDESC_SORTDESCRIPTION GetSortDescription(); - /// Gets the localized display string that describes the current sort order. - /// TRUE if ppszDescription should reference the string "Z on top"; FALSE to reference the string "A on top". - /// When this method returns, contains the address of a pointer to the sort description as a null-terminated Unicode string. - SafeCoTaskMemString GetSortDescriptionLabel([In, MarshalAs(UnmanagedType.Bool)] bool fDescending); - /// Gets a value that describes how the property values are displayed when multiple items are selected in the UI. - /// When this method returns, contains a pointer to a value that indicates the aggregation type. - PROPDESC_AGGREGATION_TYPE GetAggregationType(); - /// Gets the condition type and default condition operation to use when displaying the property in the query builder UI. This influences the list of predicate conditions (for example, equals, less than, and contains) that are shown for this property. - /// A pointer to a value that indicates the condition type. - /// When this method returns, contains a pointer to a value that indicates the default condition operation. - void GetConditionType(out PROPDESC_CONDITION_TYPE pcontype, out CONDITION_OPERATION popDefault); - /// Gets an instance of an IPropertyEnumTypeList, which can be used to enumerate the possible values for a property. - /// Reference to the interface ID of the requested interface. - /// When this method returns, contains the address of an IPropertyEnumTypeList interface pointer. - [return: MarshalAs(UnmanagedType.Interface)] - IPropertyEnumTypeList GetEnumTypeList([MarshalAs(UnmanagedType.LPStruct)] Guid riid); - /// Coerces the value to the canonical value, according to the property description. - /// On entry, contains a pointer to a PROPVARIANT structure that contains the original value. When this method returns, contains the canonical value. - [PreserveSig] - HRESULT CoerceToCanonicalValue([In, Out] PROPVARIANT propvar); - /// Gets a formatted, Unicode string representation of a property value. - /// A reference to a PROPVARIANT structure that contains the type and value of the property. - /// One or more of the PROPDESC_FORMAT_FLAGS flags, which are either bitwise or multiple values, that indicate the property string format. - /// When this method returns, contains the formatted value as a null-terminated, Unicode string. The calling application must allocate memory for the buffer, and use CoTaskMemFree to release the string specified by pszText when it is no longer needed. - SafeCoTaskMemString FormatForDisplay([In] PROPVARIANT propvar, [In] PROPDESC_FORMAT_FLAGS pdfFlags); - /// Gets a value that indicates whether a property is canonical according to the definition of the property description. - /// A reference to a PROPVARIANT structure that contains the type and value of the property. - /// Returns one of the following values: S_OK = The value is canonical; S_FALSE = The value is not canonical. - [PreserveSig] - HRESULT IsValueCanonical([In] PROPVARIANT propvar); - } - - [ComImport, Guid("57d2eded-5062-400e-b107-5dae79fe57a6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [PInvokeData("Propsys.h", MSDNShortId = "bb761561")] - public interface IPropertyDescription2 : IPropertyDescription - { - /// Gets a structure that acts as a property's unique identifier. - /// When this method returns, contains a pointer to a PROPERTYKEY structure. - new PROPERTYKEY GetPropertyKey(); - /// Gets the case-sensitive name by which a property is known to the system, regardless of its localized name. - /// When this method returns, contains the address of a pointer to the property's canonical name as a null-terminated Unicode string. - new SafeCoTaskMemString GetCanonicalName(); - /// Gets the variant type of the property. - /// When this method returns, contains a pointer to a VARTYPE that indicates the property type. If the property is multi-valued, the value pointed to is a VT_VECTOR mask (VT_VECTOR ORed to the VARTYPE. - new VARTYPE GetPropertyType(); - /// Gets the display name of the property as it is shown in any UI. - /// Contains the address of a pointer to the property's name as a null-terminated Unicode string. - [PreserveSig] - new HRESULT GetDisplayName(out SafeCoTaskMemString pszName); - /// Gets the text used in edit controls hosted in various dialog boxes. - /// When this method returns, contains the address of a pointer to a null-terminated Unicode buffer that holds the invitation text. - new SafeCoTaskMemString GetEditInvitation(); - /// Gets a set of flags that describe the uses and capabilities of the property. - /// A mask that specifies which type flags to retrieve. A combination of values found in the PROPDESC_TYPE_FLAGS constants. To retrieve all type flags, pass PDTF_MASK_ALL - /// When this method returns, contains a pointer to a value that consists of bitwise PROPDESC_TYPE_FLAGS values. - new PROPDESC_TYPE_FLAGS GetTypeFlags([In] PROPDESC_TYPE_FLAGS mask); - /// Gets the current set of flags governing the property's view. - /// When this method returns, contains a pointer to a value that includes one or more of the following flags. See PROPDESC_VIEW_FLAGS for valid values. - new PROPDESC_VIEW_FLAGS GetViewFlags(); - /// Gets the default column width of the property in a list view. - /// A pointer to the column width value, in characters. - new uint GetDefaultColumnWidth(); - /// Gets the current data type used to display the property. - /// Contains a pointer to a value that indicates the display type. - new PROPDESC_DISPLAYTYPE GetDisplayType(); - /// Gets the column state flag, which describes how the property should be treated by interfaces or APIs that use this flag. - /// When this method returns, contains a pointer to the column state flag. - new SHCOLSTATE GetColumnState(); - /// Gets the grouping method to be used when a view is grouped by a property, and retrieves the grouping type. - /// Receives a pointer to a flag value that indicates the grouping type. - new PROPDESC_GROUPING_RANGE GetGroupingRange(); - /// Gets the relative description type for a property description. - /// When this method returns, contains a pointer to the relative description type value. See PROPDESC_RELATIVEDESCRIPTION_TYPE for valid values. - new PROPDESC_RELATIVEDESCRIPTION_TYPE GetRelativeDescriptionType(); - /// Compares two property values in the manner specified by the property description. Returns two display strings that describe how the two properties compare. - /// A reference to a PROPVARIANT structure that contains the type and value of the first property. - /// A reference to a PROPVARIANT structure that contains the type and value of the second property. - /// When this method returns, contains the address of a pointer to the description string that compares the first property with the second property. The string is null-terminated. - /// When this method returns, contains the address of a pointer to the description string that compares the second property with the first property. The string is null-terminated. - new void GetRelativeDescription([In] PROPVARIANT propvar1, [In] PROPVARIANT propvar2, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDesc1, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDesc2); - /// Gets the current sort description flags for the property, which indicate the particular wordings of sort offerings. - /// When this method returns, contains a pointer to the value of one or more of the following flags that indicate the sort types available to the user. Note that the strings shown are English versions only. Localized strings are used for other locales. - new PROPDESC_SORTDESCRIPTION GetSortDescription(); - /// Gets the localized display string that describes the current sort order. - /// TRUE if ppszDescription should reference the string "Z on top"; FALSE to reference the string "A on top". - /// When this method returns, contains the address of a pointer to the sort description as a null-terminated Unicode string. - new SafeCoTaskMemString GetSortDescriptionLabel([In, MarshalAs(UnmanagedType.Bool)] bool fDescending); - /// Gets a value that describes how the property values are displayed when multiple items are selected in the UI. - /// When this method returns, contains a pointer to a value that indicates the aggregation type. - new PROPDESC_AGGREGATION_TYPE GetAggregationType(); - /// Gets the condition type and default condition operation to use when displaying the property in the query builder UI. This influences the list of predicate conditions (for example, equals, less than, and contains) that are shown for this property. - /// A pointer to a value that indicates the condition type. - /// When this method returns, contains a pointer to a value that indicates the default condition operation. - new void GetConditionType(out PROPDESC_CONDITION_TYPE pcontype, out CONDITION_OPERATION popDefault); - /// Gets an instance of an IPropertyEnumTypeList, which can be used to enumerate the possible values for a property. - /// Reference to the interface ID of the requested interface. - /// When this method returns, contains the address of an IPropertyEnumTypeList interface pointer. - [return: MarshalAs(UnmanagedType.Interface)] - new IPropertyEnumTypeList GetEnumTypeList([MarshalAs(UnmanagedType.LPStruct)] Guid riid); - /// Coerces the value to the canonical value, according to the property description. - /// On entry, contains a pointer to a PROPVARIANT structure that contains the original value. When this method returns, contains the canonical value. - [PreserveSig] - new HRESULT CoerceToCanonicalValue([In, Out] PROPVARIANT propvar); - /// Gets a formatted, Unicode string representation of a property value. - /// A reference to a PROPVARIANT structure that contains the type and value of the property. - /// One or more of the PROPDESC_FORMAT_FLAGS flags, which are either bitwise or multiple values, that indicate the property string format. - /// When this method returns, contains the formatted value as a null-terminated, Unicode string. The calling application must allocate memory for the buffer, and use CoTaskMemFree to release the string specified by pszText when it is no longer needed. - new SafeCoTaskMemString FormatForDisplay([In] PROPVARIANT propvar, [In] PROPDESC_FORMAT_FLAGS pdfFlags); - /// Gets a value that indicates whether a property is canonical according to the definition of the property description. - /// A reference to a PROPVARIANT structure that contains the type and value of the property. - /// Returns one of the following values: S_OK = The value is canonical; S_FALSE = The value is not canonical. - [PreserveSig] - new HRESULT IsValueCanonical([In] PROPVARIANT propvar); - /// Gets the image reference associated with a property value. - /// The PROPVARIANT for which to get an image. - /// A string that receives, when this method returns successfully, a string of the form <dll name>,-<resid> that is suitable to be passed to PathParseIconLocation. - /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - [PreserveSig] - HRESULT GetImageReferenceForValue([In] PROPVARIANT propvar, out SafeCoTaskMemString ppszImageRes); - } - - [ComImport, Guid("1F9FC1D0-C39B-4B26-817F-011967D3440E"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [PInvokeData("Propsys.h", MSDNShortId = "bb761511")] - public interface IPropertyDescriptionList - { - uint GetCount(); - IPropertyDescription GetAt([In] uint iElem, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); - } - - /// - /// Exposes methods that extract data from enumeration information. IPropertyEnumType gives access to the enum and enumRange elements in the property - /// schema in a programmatic way at run time. - /// - [ComImport, Guid("11e1fbf9-2d56-4a6b-8db3-7cd193a471f2"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [PInvokeData("Propsys.h")] - public interface IPropertyEnumType - { - /// Gets an enumeration type from an enumeration information structure. - /// When this method returns, contains a value that indicate the enumeration type. - PROPENUMTYPE GetEnumType(); - /// Gets a value from an enumeration information structure. - /// When this method returns, contains a pointer to the property value. - void GetValue([Out] PROPVARIANT ppropvar); - /// Gets a minimum value from an enumeration information structure. - /// When this method returns, contains a pointer to the minimum value. - void GetRangeMinValue([Out] PROPVARIANT ppropvarMin); - /// Gets a set value from an enumeration information structure. - /// When this method returns, contains a pointer to the set value. - void GetRangeSetValue([Out] PROPVARIANT ppropvarSet); - /// Gets display text from an enumeration information structure. - /// When this method returns, contains the address of a pointer to a null-terminated Unicode string that contains the display text. - void GetDisplayText([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszDisplay); - } - - /// Exposes methods that extract data from enumeration information. IPropertyEnumType2 extends IPropertyEnumType. - /// - [ComImport, Guid("9b6e051c-5ddd-4321-9070-fe2acb55e794"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [PInvokeData("Propsys.h")] - public interface IPropertyEnumType2 : IPropertyEnumType - { - /// Gets an enumeration type from an enumeration information structure. - /// When this method returns, contains a value that indicate the enumeration type. - new PROPENUMTYPE GetEnumType(); - /// Gets a value from an enumeration information structure. - /// When this method returns, contains a pointer to the property value. - new void GetValue([Out] PROPVARIANT ppropvar); - /// Gets a minimum value from an enumeration information structure. - /// When this method returns, contains a pointer to the minimum value. - new void GetRangeMinValue([Out] PROPVARIANT ppropvarMin); - /// Gets a set value from an enumeration information structure. - /// When this method returns, contains a pointer to the set value. - new void GetRangeSetValue([Out] PROPVARIANT ppropvarSet); - /// Gets display text from an enumeration information structure. - /// When this method returns, contains the address of a pointer to a null-terminated Unicode string that contains the display text. - new void GetDisplayText([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszDisplay); - /// Retrieves the image reference associated with a property enumeration. - /// A pointer to a buffer that, when this method returns successfully, receives a string of the form <dll name>,-<resid> that is suitable to be passed to PathParseIconLocation. - [PreserveSig] HRESULT GetImageReference([Out, MarshalAs(UnmanagedType.LPWStr)] out string ppszImageRes); - } - - [ComImport, Guid("A99400F4-3D84-4557-94BA-1242FB2CC9A6"), InterfaceType(ComInterfaceType.InterfaceIsIUnknown)] - [PInvokeData("Propsys.h")] - public interface IPropertyEnumTypeList - { - uint GetCount(); - - [return: MarshalAs(UnmanagedType.Interface)] - IPropertyEnumType GetAt([In] uint itype, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); - - [return: MarshalAs(UnmanagedType.Interface)] - object GetConditionAt([In] uint index, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); - - /// Compares the specified property value against the enumerated values in a list and returns the matching index. - /// A reference to a PROPVARIANT structure that represents the property value. - /// When this method returns, contains a pointer to the index in the enumerated type list that matches the property value, if any. - /// If this method succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. - [PreserveSig] - HRESULT FindMatchingIndex([In] PROPVARIANT propvarCmp, out uint pnIndex); - } - - [SuppressUnmanagedCodeSecurity] - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("886d8eeb-8cf2-4446-8d02-cdba1dbdcf99")] - [PInvokeData("Shobjidl.h", MSDNShortId = "bb762502")] - public interface IPropertyStore - { - uint GetCount(); - - PROPERTYKEY GetAt(uint iProp); - - void GetValue([In] ref PROPERTYKEY pkey, [In, Out] PROPVARIANT pv); - - void SetValue([In] ref PROPERTYKEY pkey, [In] PROPVARIANT pv); - - void Commit(); - } - - [SuppressUnmanagedCodeSecurity] - [ComImport, InterfaceType(ComInterfaceType.InterfaceIsIUnknown), Guid("ca724e8a-c3e6-442b-88a4-6fb0db8035a3")] - [PInvokeData("PropSys.h")] - public interface IPropertySystem - { - [return: MarshalAs(UnmanagedType.Interface)] - IPropertyDescription GetPropertyDescription(ref PROPERTYKEY propkey, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); - - [return: MarshalAs(UnmanagedType.Interface)] - IPropertyDescription GetPropertyDescriptionByName([In, MarshalAs(UnmanagedType.LPWStr)] string pszCanonicalName, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); - - [return: MarshalAs(UnmanagedType.Interface)] - IPropertyDescriptionList GetPropertyDescriptionListFromString([In, MarshalAs(UnmanagedType.LPWStr)] string pszPropList, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); - - [return: MarshalAs(UnmanagedType.Interface)] - IPropertyDescriptionList EnumeratePropertyDescriptions(PROPDESC_ENUMFILTER filterOn, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid); - - void FormatForDisplay(ref PROPERTYKEY key, PROPVARIANT propvar, PROPDESC_FORMAT_FLAGS pdff, System.Text.StringBuilder pszText, uint cchText); - - SafeCoTaskMemString FormatForDisplayAlloc(ref PROPERTYKEY key, PROPVARIANT propvar, PROPDESC_FORMAT_FLAGS pdff); - - void RegisterPropertySchema([In, MarshalAs(UnmanagedType.LPWStr)] string pszPath); - - void UnregisterPropertySchema([In, MarshalAs(UnmanagedType.LPWStr)] string pszPath); - - void RefreshPropertySchema(); - } - /// /// Retrieves the property's canonical name given its PROPERTYKEY. /// @@ -758,7 +149,7 @@ namespace Vanara.PInvoke /// The result of the operation. S_OK indicates success. [DllImport(Lib.PropSys, ExactSpelling = true)] [PInvokeData("Propsys.h", MSDNShortId = "bb776502")] - public static extern HRESULT PSGetNameFromPropertyKey(ref PROPERTYKEY propkey, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszCanonicalName); + public static extern HRESULT PSGetNameFromPropertyKey([In, MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY propkey, [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszCanonicalName); /// Gets an instance of a property description interface for a property specified by a PROPERTYKEY structure. /// Reference to a PROPERTYKEY. @@ -770,7 +161,7 @@ namespace Vanara.PInvoke /// The result of the operation. S_OK indicates success. [DllImport(Lib.PropSys, ExactSpelling = true)] [PInvokeData("Propsys.h", MSDNShortId = "bb776503")] - public static extern HRESULT PSGetPropertyDescription(ref PROPERTYKEY propkey, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + public static extern HRESULT PSGetPropertyDescription([In, MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY propkey, [MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); /// Gets the property key for a canonical property name. /// Pointer to a property name as a null-terminated, Unicode string. @@ -779,5 +170,445 @@ namespace Vanara.PInvoke [DllImport(Lib.PropSys, ExactSpelling = true)] [PInvokeData("Propsys.h", MSDNShortId = "bb762081")] public static extern HRESULT PSGetPropertyKeyFromName([MarshalAs(UnmanagedType.LPWStr)] string pszName, out PROPERTYKEY ppropkey); + + /// Converts the value of a property to the canonical value, according to the property description.Type: REFPROPERTYKEYReference to a PROPERTYKEY structure that identifies the property whose value is to be coerced.Type: PROPVARIANT*On entry, contains a pointer to a PROPVARIANT structure that contains the original value. When this function returns successfully, contains the canonical value.Type: HRESULTPossible return values include the following:Return codeDescription S_OK The function succeeded. The property value specified by ppropvar is now in a canonical form. INPLACE_S_TRUNCATED The property value specified by ppropvar is now in a truncated, canonical form. E_INVALIDARG The ppropvar parameter is invalid. The PROPVARIANT structure has been cleared. TYPE_E_TYPEMISMATCH Coercion from the value's type to the property description's type was not possible. The PROPVARIANT structure has been cleared. Any other failure code Coercion from the value's type to the property description's type was not possible. The PROPVARIANT structure has been cleared. This function is a wrapper around the system's implementation of IPropertyDescription::CoerceToCanonicalValue.Most property descriptions specify the type that their values are expected to use. For example, the property description for System.Title specifies that System.Title values should be of type VT_LPWSTR. This function coerces values to this type, and then coerces the result into a canonical form.It is important to note that if this function fails, it will have already called PropVariantClear on the input PROPVARIANT structure. Only if this function succeeds is the calling application responsible for calling PropVariantClear on ppropvar when the structure is no longer needed.The coercion performed by this function is also performed by the property system during calls to IPropertyStore::GetValue and IPropertyStore::SetValue. Applications can either depend on the property system to perform the coercions or can use this function to perform the coercion at a time of the application's choosing.The coercion is performed in four steps, as follows:The following values are converted to VT_EMPTY. If the value is not of type VT_EMPTY after Step 1, it is converted to the type specified by the property description. The type of a property description can be obtained by calling IPropertyDescription::GetPropertyType. For information on how the property schema influences the type of a property description, see typeInfo. Conversions are performed as follows: After Steps 2 and 3, the value is coerced into a canonical form based on its type. The canonical forms are summarized in the following table. If applicable, the value is checked against the property description type enumeration. The checks in the following table apply. ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSCoerceToCanonicalValue to coerce a value to the type required for PKEY_Keywords. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pscoercetocanonicalvalue + // PSSTDAPI PSCoerceToCanonicalValue( REFPROPERTYKEY key, PROPVARIANT *ppropvar ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "8225dd01-47cc-451e-b6a6-c16ddf62ca20")] + public static extern HRESULT PSCoerceToCanonicalValue([In, MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY key, PROPVARIANT ppropvar); + + /// + /// Creates an adapter from an IPropertyStore. + /// + /// + /// Type: IPropertyStore* + /// Pointer to an IPropertyStore object that represents the property store. + /// + /// + /// Type: REFIID + /// Reference to an IID. + /// + /// + /// Type: void** + /// When this function returns, contains the interface pointer requested in riid. + /// + /// + /// Type: HRESULT + /// If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code. + /// + /// + /// The adapter object implements IPropertySetStorage, IPropertyStore, IPropertyStoreCapabilities, and IObjectProvider. + /// + /// Use this function if you need an object that implements IPropertyStore with an API that requires an IPropertySetStorage + /// interface. The object created can also be useful to a namespace extension that wants to provide support for binding to namespace + /// items using IPropertySetStorage. Applications must call this object from only one thread at a time. + /// + /// + /// The adapter property store created by this function retains a reference to the source IPropertyStore interface. Therefore, the + /// calling application is free to release its reference to the source IPropertyStore whenever convenient after calling this function. + /// + /// + /// The adapter property store makes calls to methods on the IPropertyStore interface as appropriate. Therefore, if the calling + /// application is writing values to the store, it should call the IPropertyStore::Commit method on only one of the interfaces. + /// + /// Examples + /// + /// The following example, to be included as part of a larger program, demonstrates how to use PSCreateAdapterFromPropertyStore to + /// use an adapter property store to convert an IPropertyStore interface into an IPropertySetStorage interface. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pscreateadapterfrompropertystore + // PSSTDAPI PSCreateAdapterFromPropertyStore( IPropertyStore *pps, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "a3489f95-e790-481a-af6e-f30527dc476c")] + public static extern HRESULT PSCreateAdapterFromPropertyStore(IPropertyStore pps, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Creates a read-only, delayed-binding property store that contains multiple property stores.Type: GETPROPERTYSTOREFLAGSOne or more GETPROPERTYSTOREFLAGS values. These values specify details of the created property store object.Type: IDelayedPropertyStoreFactory*Interface pointer to an instance of IDelayedPropertyStoreFactory.Type: const DWORD*Pointer to an array of property store IDs. This array does not need to be initialized.Type: DWORDThe number of elements in the array pointed to by rgStoreIds.Type: REFIIDReference to the requested IID of the interface that will represent the created property store.Type: void**When this function returns, contains the interface pointer requested in riid. This is typically IPropertyStore.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.This function creates a Component Object Model (COM) object that implements IPropertyStore, INamedPropertyStore, IObjectProvider, and IPropertyStoreCapabilities.Applications must call this object from only one thread at a time.You must initialize COM with CoInitialize or OleInitialize before you call PSCreateDelayedMultiplexPropertyStore. COM must remain initialized for the lifetime of this object.PSCreateDelayedMultiplexPropertyStore is designed as an alternative to PSCreateMultiplexPropertyStore, which requires that the array of property stores be initialized before it creates the multiplex property store.The delayed binding mechanism is designed as a performance enhancement for calls to IPropertyStore::GetValue on a multiplex property store. When asked for the value of a property, the delayed multiplex property store checks each of the property stores for the value. After the value is found, there is no need to create and initialize subsequent stores. The delayed multiplex property store stops searching for a value when one of the property stores returns a success code and a non-VT_EMPTY value.When the delayed multiplex property store needs to access a particular property store, it first checks to see if it has already obtained an interface to that property store. If not, it calls IDelayedPropertyStoreFactory::GetDelayedPropertyStore with the appropriate property store ID to obtain the property store. It always uses the property store IDs in the order in which they are provided by the application. It is possible that not all IDs will be used.If the call to IDelayedPropertyStoreFactory fails with E_NOTIMPL or E_ACCESSDENIED for a particular property store ID, or if the application specified GPS_BESTEFFORT, then the failure is ignored and the delayed multiplex property store moves on to the next property store.In some cases, it might be beneficial to use PSCreateDelayedMultiplexPropertyStore in place of PSCreateMultiplexPropertyStore. For example, if an application needs to multiplex two property stores and the first property store is not memory-intensive to initialize and provides PKEY_Size information. Often, calling applications ask for a multiplex property store and then ask for only PKEY_Size before they release the object. In such a case, the application could avoid the cost of initializing the second property store by calling PSCreateDelayedMultiplexPropertyStore and implementing IDelayedPropertyStoreFactory.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSCreateDelayedMultiplexPropertyStore in an implementation of IPropertyStoreFactory::GetPropertyStore. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pscreatedelayedmultiplexpropertystore + // PSSTDAPI PSCreateDelayedMultiplexPropertyStore( GETPROPERTYSTOREFLAGS flags, IDelayedPropertyStoreFactory *pdpsf, const DWORD *rgStoreIds, DWORD cStores, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "8b264d7e-6124-4724-8d23-605101705893")] + public static extern HRESULT PSCreateDelayedMultiplexPropertyStore(GETPROPERTYSTOREFLAGS flags, IDelayedPropertyStoreFactory pdpsf, + [In, MarshalAs(UnmanagedType.LPArray, SizeParamIndex = 3)] uint[] rgStoreIds, uint cStores, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, + [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Creates an in-memory property store.Type: REFIIDReference to the requested interface ID.Type: void**When this function returns, contains a pointer to the desired interface, typically IPropertyStore or IPersistSerializedPropStorage.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.This function creates an in-memory property store object that implements IPropertyStore, INamedPropertyStore, IPropertyStoreCache, IPersistStream, IPropertyBag, and IPersistSerializedPropStorage.The memory property store does not correspond to a file and is designed for use as a cache. IPropertyStore::Commit is a no-op, and the data stored in the object persists only as long as the object does.The memory property store is thread safe. It aggregates the free-threaded marshaller and uses critical sections to protect its data members.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSCreateMemoryPropertyStore. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pscreatememorypropertystore + // PSSTDAPI PSCreateMemoryPropertyStore( REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "6e7a2ac0-2a4a-41ec-a2a8-ddbe8aa45bc9")] + public static extern HRESULT PSCreateMemoryPropertyStore([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Creates a read-only property store that contains multiple property stores, each of which must support either IPropertyStore or IPropertySetStorage.Type: IUnknown**Address of a pointer to an array of property stores that implement either IPropertyStore or IPropertySetStorage.Type: DWORDThe number of elements in the array referenced in prgpunkStores.Type: REFIIDReference to the requested IID.Type: void**When this function returns, contains the interface pointer requested in riid. This is typically IPropertyStore.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.This function creates a Component Object Model (COM) object that implements IPropertyStore, INamedPropertyStore, IObjectProvider, and IPropertyStoreCapabilities. The multiplex property store object aggregates the properties exposed from multiple property stores.This object can be useful for aggregating the properties from multiple existing property store implementations in a Shell namespace extension, or for reusing an existing property store and providing additional read-only properties.Applications must call this object from only one thread at a time.You must initialize COM with CoInitialize or OleInitialize before you call PSCreateDelayedMultiplexPropertyStore. COM must remain initialized for the lifetime of this object.Each of the objects in the array prgpunkStores must implement either IPropertyStore or IPropertySetStorage. If an object implements IPropertySetStorage, it is wrapped using PSCreatePropertyStoreFromPropertySetStorage for use in the multiplex property store.The multiplex property store implementation of IPropertyStore::GetValue asks each of the provided property stores for the value. The multiplex property store stops searching when one of the property stores returns a success code and a non-VT_EMPTY value. Failure codes cause the search to end and are passed back to the calling application.The multiplex property store implementation of IPropertyStoreCapabilities::IsPropertyWritable delegates the call to the first store that implements IPropertyStoreCapabilities. If multiple stores implement IPropertyStoreCapabilities, the subsequent ones are ignored. If no store implements IPropertyStoreCapabilities, this method returns S_OK.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSCreateMultiplexPropertyStore in an implementation of IPropertyStoreFactory::GetPropertyStore. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pscreatemultiplexpropertystore + // PSSTDAPI PSCreateMultiplexPropertyStore( IUnknown **prgpunkStores, DWORD cStores, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "4a6b5a10-5ef2-42c7-bf3b-dfa743be252f")] + public static extern HRESULT PSCreateMultiplexPropertyStore([MarshalAs(UnmanagedType.LPArray, ArraySubType = UnmanagedType.IUnknown, SizeParamIndex = 1)] object[] prgpunkStores, + uint cStores, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Accepts the IUnknown interface of an object that supports IPropertyStore or IPropertySetStorage. If the object supports IPropertySetStorage, it is wrapped so that it supports IPropertyStore.Type: IUnknown*A pointer to an interface that supports either IPropertyStore or IPropertySetStorage.Type: DWORDSpecifies the access mode to use. One of these values:STGM_READOpen for reading.STGM_READWRITEOpen for reading and writing.Type: REFIIDReference to the requested IID.Type: void**When this function returns successfully, contains the address of a pointer to an interface guaranteed to support IPropertyStore.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.If the object pointed to by punk already supports IPropertyStore, no wrapper is created and the punk is returned unaltered. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pscreatepropertystorefromobject + // PSSTDAPI PSCreatePropertyStoreFromObject( IUnknown *punk, DWORD grfMode, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "010572d5-0357-4101-803e-0a27fc60ca5e")] + public static extern HRESULT PSCreatePropertyStoreFromObject([MarshalAs(UnmanagedType.IUnknown)] object punk, STGM grfMode, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, + [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Wraps an IPropertySetStorage interface in an IPropertyStore interface.Type: IPropertySetStorage*A pointer to an IPropertySetStorage interface.Type: DWORDSpecifies the access mode to enforce. grfMode should match the access mode used to open the IPropertySetStorage. Valid values are as follows:STGM_READCalls to IPropertyStore::SetValueupdate an internal cache of properties, and calls to IPropertyStore::Commitcall the appropriate IPropertySetStorage methods to write out the changed properties.STGM_WRITENot supported.STGM_READWRITENot supported.Type: REFIIDReference to an IID.Type: void**When this function returns, contains the interface pointer specified in riid.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.This function wraps an IPropertySetStorage interface in an IPropertyStore interface. Any value other than STGM_READ for grfMode, causes calls to IPropertyStore::SetValue and IPropertyStore::Commit to fail with STG_E_ACCESSDENIED. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pscreatepropertystorefrompropertysetstorage + // PSSTDAPI PSCreatePropertyStoreFromPropertySetStorage( IPropertySetStorage *ppss, DWORD grfMode, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "efba5a2a-df26-4f7e-9ddf-ec471e3d547c")] + public static extern HRESULT PSCreatePropertyStoreFromPropertySetStorage(IPropertySetStorage ppss, STGM grfMode, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// A wrapper API that calls the schema subsystem's IPropertySystem::EnumeratePropertyDescriptions. This function retrieves an instance of the subsystem object that implements IPropertyDescriptionList, to obtain either the entire list or a partial list of property descriptions in the system.Type: PROPDESC_ENUMFILTERThe list to return. PROPDESC_ENUMFILTER shows the valid values for this method.Type: REFIIDReference to the interface ID of the requested interface.Type: void**The address of an IPropertyDescriptionList interface pointer.Type: PSSTDAPIReturns one of the following values.Return codeDescription S_OK Indicates an interface is obtained. E_INVALIDARG Indicates that ppv is NULL. We recommend that you use the IID_PPV_ARGS macro, defined in objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, eliminating the possibility of a coding error. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psenumeratepropertydescriptions + // PSSTDAPI PSEnumeratePropertyDescriptions( PROPDESC_ENUMFILTER filterOn, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "687d5a32-3a2e-4b9b-b06c-ca06a6cd1595")] + public static extern HRESULT PSEnumeratePropertyDescriptions(PROPDESC_ENUMFILTER filterOn, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Gets a formatted, Unicode string representation of a property value stored in a PROPVARIANT structure. The caller is responsible for allocating the output buffer.Type: REFPROPERTYKEYReference to a PROPERTYKEY that names the property whose value is being retrieved.Type: REFPROPVARIANTReference to a PROPVARIANT structure that contains the type and value of the property.Type: PROPDESC_FORMAT_FLAGSA flag that specifies the format to apply to the property string. See PROPDESC_FORMAT_FLAGS for possible values.Type: LPWSTRWhen the function returns, contains a pointer to the formatted value as a null-terminated, Unicode string. The calling application is responsible for allocating memory for the buffer before it calls PSFormatForDisplay.Type: DWORDSpecifies the length of the buffer at pwszText in WCHARs, including the terminating null character.Type: HRESULTReturns one of the following values.Return codeDescription S_OK The formatted string was successfully created. S_FALSE The formatted string was not created. S_FALSE indicates that an empty string resulted from a VT_EMPTY. E_OUTOFMEMORY Indicates allocation failed.This function calls the schema subsystem's implementation of IPropertySystem::FormatForDisplay. That call provides a Unicode string representation of a property value, with additional formatting based on one or more PROPDESC_FORMAT_FLAGS. If the PROPERTYKEY is not recognized by the schema subsystem, IPropertySystem::FormatForDisplay attempts to format the value according to the value's VARTYPE.You must initialize Component Object Model (COM) with CoInitialize or OleInitialize before you call PSFormatPropertyValue.The purpose of this function is to convert data into a string suitable for display to the user. The value is formatted according to the current locale, the language of the user, the PROPDESC_FORMAT_FLAGS, and the property description specified by the property key. For information on how the property description schema influences the formatting of the value, see the following topics:displayInfostringFormatbooleanFormatnumberFormatNMDATETIMEFORMATenumeratedListTypically, the PROPDESC_FORMAT_FLAGS are used to modify the format prescribed by the property description.The output string can contain Unicode directional characters. These nonspacing characters influence the Unicode bidirectional algorithm so that the values appear correctly when a left-to-right (LTR) language is drawn on a right-to-left (RTL) window, or an RTL is drawn on a LTR window. These characters include the following: The following properties use special formats and are unaffected by the PROPDESC_FORMAT_FLAGS. Note that examples cited are for strings with a current locale set to English; typically, output is localized except where noted.PropertyFormatSystem.FileAttributesThe following file attributes are converted to letters and appended to create a string (for example, a value of 0x1801 is converted to "RCO"):FILE_ATTRIBUTE_READONLY- 'R'FILE_ATTRIBUTE_SYSTEM - 'S'FILE_ATTRIBUTE_ARCHIVE -'A'FILE_ATTRIBUTE_COMPRESSED - 'C'FILE_ATTRIBUTE_ENCRYPTED - 'E'FILE_ATTRIBUTE_OFFLINE - 'O'FILE_ATTRIBUTE_NOT_CONTENT_INDEXED - 'I'System.Photo.ISOSpeedFor example, "ISO-400".System.Photo.ShutterSpeed The APEX value is converted to an exposure time using this formula: For example, "2 sec."or "1/125 sec.".System.Photo.ExposureTimeFor example, "2 sec."or "1/125 sec."System.Photo.Aperture The APEX value is converted to an F number using this formula: For example, "f/5.6".System.Photo.FNumberFor example, "f/5.6".System.Photo.SubjectDistanceFor example, "15 m"or "250 mm".System.Photo.FocalLengthFor example, "50 mm".System.Photo.FlashEnergyFor example, "500 bpcs".System.Photo.ExposureBiasFor example, "-2 step", " 0 step", or "+3 step".System.Computer.DecoratedFreeSpaceFor example, "105 MB free of 13.2 GB".System.ItemTypeFor example, "Application" or "JPEG Image".System.ControlPanel.CategoryFor example, "Appearance and Personalization".System.ComputerNameFor example, "LITWARE05 (this computer)" or "testbox07".If the property key does not correspond to a property description in any of the registered property schemas, then this function chooses a format based on the type of the value.Type of the valueFormatVT_BOOLEANNot supported.VT_FILETIMEDate/time string as specified by PROPDESC_FORMAT_FLAGS and the current locale. PDFF_SHORTTIME and PDFF_SHORTDATE are the default. For example, "11/13/2006 3:22 PM".Numeric VARTYPEDecimal string in the current locale. For example, "42".VT_LPWSTR or otherConverted to a string. Sequences of "\r", "\t", or "\n" are replaced with a single space.VT_VECTOR | anythingSemicolon separated values. A semicolon is used regardless of locale.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSFormatForDisplay to format a rating value. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psformatfordisplay + // PSSTDAPI PSFormatForDisplay( REFPROPERTYKEY propkey, REFPROPVARIANT propvar, PROPDESC_FORMAT_FLAGS pdfFlags, LPWSTR pwszText, DWORD cchText ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "71442967-ee8a-448c-83cf-949934ddd152")] + public static extern HRESULT PSFormatForDisplay([In, MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY propkey, PROPVARIANT propvar, PROPDESC_FORMAT_FLAGS pdfFlags, + [MarshalAs(UnmanagedType.LPWStr)] StringBuilder pwszText, uint cchText); + + /// + /// + /// Gets a formatted, Unicode string representation of a property value stored in a PROPVARIANT structure. This function allocates + /// memory for the output string. + /// + /// + /// + /// Type: REFPROPERTYKEY + /// Reference to a PROPERTYKEY that names the property whose value is being retrieved. + /// + /// + /// Type: REFPROPVARIANT + /// Reference to a PROPVARIANT structure that contains the type and value of the property. + /// + /// + /// Type: PROPDESC_FORMAT_FLAGS + /// One or more flags that specify the format to apply to the property string. See PROPDESC_FORMAT_FLAGS for possible values. + /// + /// + /// Type: PWSTR* + /// + /// When the function returns, contains a pointer to a null-terminated, Unicode string representation of the requested property value. + /// + /// + /// + /// Type: HRESULT + /// Returns one of the following values. + /// + /// + /// Return code + /// Description + /// + /// + /// S_OK + /// + /// The formatted string was successfully created. S_OK together with an empty return string indicates that there was an empty input + /// string or a non-empty value that was formatted as an empty string. + /// + /// + /// + /// S_FALSE + /// + /// The formatted string was not created. S_FALSE together with an empty return string indicates that the empty string resulted from + /// a VT_EMPTY. + /// + /// + /// + /// E_OUTOFMEMORY + /// Indicates allocation failed. + /// + /// + /// + /// + /// + /// This function calls the schema subsystem's implementation of IPropertySystem::FormatForDisplayAlloc. That call provides a Unicode + /// string representation of a property value, with additional formatting based on one or more PROPDESC_FORMAT_FLAGS. If the + /// PROPERTYKEY is not recognized by the schema subsystem, IPropertySystem::FormatForDisplayAlloc attempts to format the value + /// according to the value's VARTYPE. + /// + /// You must initialize Component Object Model (COM) with CoInitialize or OleInitialize before you call PSFormatForDisplayAlloc. + /// + /// The function allocates memory through CoTaskMemAlloc and returns a pointer to that memory through the ppszDisplay parameter. The + /// calling application must use CoTaskMemFree to release that resource when it is no longer needed. + /// + /// + /// The purpose of this function is to convert data into a string suitable for display to the user. The value is formatted according + /// to the current locale, the language of the user, the PROPDESC_FORMAT_FLAGS, and the property description specified by the + /// property key. For information on how the property description schema influences the formatting of the value, see the following topics: + /// + /// + /// + /// displayInfo + /// + /// + /// stringFormat + /// + /// + /// booleanFormat + /// + /// + /// numberFormat + /// + /// + /// NMDATETIMEFORMAT + /// + /// + /// enumeratedList + /// + /// + /// Typically, the PROPDESC_FORMAT_FLAGS are used to modify the format prescribed by the property description. + /// + /// The output string can contain Unicode directional characters. These nonspacing characters influence the Unicode bidirectional + /// algorithm so that the values appear correctly when a left-to-right (LTR) language is drawn on a right-to-left (RTL) window, or an + /// RTL is drawn on a LTR window. These characters include the following: + /// + /// + /// The following properties use special formats and are unaffected by the PROPDESC_FORMAT_FLAGS. Note that examples cited are for + /// strings with a current locale set to English; typically, output is localized except where noted. + /// + /// + /// + /// Property + /// Format + /// + /// + /// System.FileAttributes + /// + /// The following file attributes are converted to letters and appended to create a string (for example, a value of 0x1801 + /// (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_OFFLINE) is converted to "RCO"): + /// + /// + /// + /// System.Photo.ISOSpeed + /// For example, "ISO-400". + /// + /// + /// System.Photo.ShutterSpeed + /// The APEX value is converted to an exposure time using this formula: For example, "2 sec."or "1/125 sec.". + /// + /// + /// System.Photo.ExposureTime + /// For example, "2 sec."or "1/125 sec." + /// + /// + /// System.Photo.Aperture + /// The APEX value is converted to an F number using this formula: For example, "f/5.6". + /// + /// + /// System.Photo.FNumber + /// For example, "f/5.6". + /// + /// + /// System.Photo.SubjectDistance + /// For example, "15 m"or "250 mm". + /// + /// + /// System.Photo.FocalLength + /// For example, "50 mm". + /// + /// + /// System.Photo.FlashEnergy + /// For example, "500 bpcs". + /// + /// + /// System.Photo.ExposureBias + /// For example, "-2 step", " 0 step", or "+3 step". + /// + /// + /// System.Computer.DecoratedFreeSpace + /// For example, "105 MB free of 13.2 GB". + /// + /// + /// System.ItemType + /// For example, "Application" or "JPEG Image". + /// + /// + /// System.ControlPanel.Category + /// For example, "Appearance and Personalization". + /// + /// + /// System.ComputerName + /// For example, "LITWARE05 (this computer)" or "testbox07". + /// + /// + /// + /// If the property key does not correspond to a property description in any of the registered property schemas, then this function + /// chooses a format based on the type of the value. + /// + /// + /// + /// Type of the value + /// Format + /// + /// + /// VT_BOOLEAN + /// Not supported. + /// + /// + /// VT_FILETIME + /// + /// Date/time string as specified by PROPDESC_FORMAT_FLAGS and the current locale. PDFF_SHORTTIME and PDFF_SHORTDATE are the default. + /// For example, "11/13/2006 3:22 PM". + /// + /// + /// + /// Numeric VARTYPE + /// Decimal string in the current locale. For example, "42". + /// + /// + /// VT_LPWSTR or other + /// Converted to a string. Sequences of "\r", "\t", or "\n" are replaced with a single space. + /// + /// + /// VT_VECTOR | anything + /// Semicolon separated values. A semicolon is used regardless of locale. + /// + /// + /// Examples + /// + /// The following example, to be included as part of a larger program, demonstrates how to use PSFormatForDisplayAlloc to format a + /// rating value. + /// + /// + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psformatfordisplayalloc + // PSSTDAPI PSFormatForDisplayAlloc( REFPROPERTYKEY key, REFPROPVARIANT propvar, PROPDESC_FORMAT_FLAGS pdff, PWSTR *ppszDisplay ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "d411ea72-fb29-47b6-a7f6-0839b3e2caf2")] + public static extern HRESULT PSFormatForDisplayAlloc([In, MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY key, PROPVARIANT propvar, PROPDESC_FORMAT_FLAGS pdff, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDisplay); + + /// Gets a formatted, Unicode string representation of a property value stored in a property store. This function allocates memory for the output string.Type: IPropertyStore*Pointer to an IPropertyStore, which represents the property store from which the property value is taken.Type: IPropertyDescription*Pointer to an IPropertyDescription, which represents the property whose value is being retrieved.Type: PROPDESC_FORMAT_FLAGSOne or more PROPDESC_FORMAT_FLAGS that specify the format to apply to the property string. See PROPDESC_FORMAT_FLAGS for possible values.Type: LPWSTR*When the function returns, contains a pointer to the formatted value as a null-terminated, Unicode string.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.This function uses the ppd parameter to call IPropertyDescription::FormatForDisplay. That call provides a Unicode string representation of a property value, with additional formatting based on one or more PROPDESC_FORMAT_FLAGS.You must initialize Component Object Model (COM) with CoInitialize or OleInitialize before you call PSFormatPropertyValue.The function allocates memory and returns a pointer to that memory in ppszDisplay. The calling application must use CoTaskMemFree to release the string specified by ppszDisplay when it is no longer needed.The purpose of this function is to convert data into a string suitable for display to the user. The value is formatted according to the current locale, the language of the user, the PROPDESC_FORMAT_FLAGS, and the property description specified by the property key. For information on how the property description schema influences the formatting of the value, see the following topics:displayInfostringFormatbooleanFormatnumberFormatNMDATETIMEFORMATenumeratedListTypically, the PROPDESC_FORMAT_FLAGS are used to modify the format prescribed by the property description.The output string can contain Unicode directional characters. These nonspacing characters influence the Unicode bidirectional algorithm so that the values appear correctly when a left-to-right (LTR) language is drawn on a right-to-left (RTL) window, or an RTL is drawn on a LTR window. These characters include the following: The following properties use special formats and are unaffected by the PROPDESC_FORMAT_FLAGS. Note that examples cited are for strings with a current locale set to English; typically, output is localized except where noted.PropertyFormatSystem.FileAttributesThe following file attributes are converted to letters and appended to create a string (for example, a value of 0x1801 (FILE_ATTRIBUTE_READONLY | FILE_ATTRIBUTE_COMPRESSED | FILE_ATTRIBUTE_OFFLINE) is converted to "RCO"): System.Photo.ISOSpeedFor example, "ISO-400".System.Photo.ShutterSpeed The APEX value is converted to an exposure time using this formula: For example, "2 sec."or "1/125 sec.".System.Photo.ExposureTimeFor example, "2 sec."or "1/125 sec."System.Photo.Aperture The APEX value is converted to an F number using this formula: For example, "f/5.6".System.Photo.FNumberFor example, "f/5.6".System.Photo.SubjectDistanceFor example, "15 m"or "250 mm".System.Photo.FocalLengthFor example, "50 mm".System.Photo.FlashEnergyFor example, "500 bpcs".System.Photo.ExposureBiasFor example, "-2 step", " 0 step", or "+3 step".System.Computer.DecoratedFreeSpaceFor example, "105 MB free of 13.2 GB".System.ItemTypeFor example, "Application" or "JPEG Image".System.ControlPanel.CategoryFor example, "Appearance and Personalization".System.ComputerNameFor example, "LITWARE05 (this computer)" or "testbox07".If the property key does not correspond to a property description in any of the registered property schemas, then this function chooses a format based on the type of the value.Type of the valueFormatVT_BOOLEANNot supported.VT_FILETIMEDate/time string as specified by PROPDESC_FORMAT_FLAGS and the current locale. PDFF_SHORTTIME and PDFF_SHORTDATE are the default. For example, "11/13/2006 3:22 PM".Numeric VARTYPEDecimal string in the current locale. For example, "42".VT_LPWSTR or otherConverted to a string. Sequences of "\r", "\t", or "\n" are replaced with a single space.VT_VECTOR | anythingSemicolon separated values. A semicolon is used regardless of locale.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSFormatPropertyValue to format a rating value. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psformatpropertyvalue + // PSSTDAPI PSFormatPropertyValue( IPropertyStore *pps, IPropertyDescription *ppd, PROPDESC_FORMAT_FLAGS pdff, LPWSTR *ppszDisplay ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "35c2b424-05bd-4d7d-8365-5900e165e2e2")] + public static extern HRESULT PSFormatPropertyValue(IPropertyStore pps, IPropertyDescription ppd, PROPDESC_FORMAT_FLAGS pdff, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszDisplay); + + /// Gets an instance of a property description interface for a specified property.Type: REFPROPERTYKEYA reference to a PROPERTYKEY structure that specifies the property.Type: REFIIDA reference to the IID of the interface to retrieve through ppv.Type: void**When this function returns successfully, contains the interface pointer requested in riid.Type: HRESULTReturns S_OK if successful, or an error value otherwise, including the following:Return codeDescription TYPE_E_ELEMENTNOTFOUND We recommend that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding error in riid that could lead to unexpected results. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetimagereferenceforvalue + // PSSTDAPI PSGetImageReferenceForValue( REFPROPERTYKEY propkey, REFPROPVARIANT propvar, PWSTR *ppszImageRes ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "E37AF2ED-E3F9-4e50-9317-9DAF03AC543F")] + public static extern HRESULT PSGetImageReferenceForValue([In, MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY propkey, PROPVARIANT propvar, + [MarshalAs(UnmanagedType.CustomMarshaler, MarshalTypeRef = typeof(CoTaskMemStringMarshaler))] out string ppszImageRes); + + /// Retrieves a property handler for a Shell item.Type: IUnknown*A pointer to the IUnknown interface of a Shell item that supports IShellItem.Windows XP: Use SHCreateShellItem to create the Shell item.Windows Vista: Use SHCreateItemFromIDList, SHCreateItemFromParsingName, SHCreateItemFromRelativeName, SHCreateItemInKnownFolder, or SHCreateItemWithParent to create the Shell item.Type: BOOLTRUE to retrieve a read/write property handler. FALSE to retrieve a read-only property handler.Type: REFIIDReference to the IID of the interface the handler object should return. This should be IPropertyStore or an interface derived from IPropertyStore.Type: void**When this function returns, contains the interface pointer requested in riid.Type: PSSTDAPIReturns S_OK if successful, or an error value otherwise.This function is supported in Windows XP and Windows Vista. For applications supported only on Windows Vista or later, it is recommended that you use IShellItem2::GetPropertyStore instead of PSGetItemPropertyHandler. That method provides a richer set of properties in the property store that is returned.This function is approximately equivalent to passing the GPS_HANDLERPROPERTIESONLY flag to IShellItem2::GetPropertyStore.You must initialize Component Object Model (COM) with CoInitialize or OleInitialize before you call PSGetItemPropertyHandler. COM must remain initialized for the lifetime of this object.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSGetItemPropertyHandler to obtain a property handler for an item. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetitempropertyhandler + // PSSTDAPI PSGetItemPropertyHandler( IUnknown *punkItem, BOOL fReadWrite, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "7b7fd260-c863-41f7-8594-4ee435090228")] + public static extern HRESULT PSGetItemPropertyHandler([MarshalAs(UnmanagedType.IUnknown)] object punkItem, [MarshalAs(UnmanagedType.Bool)] bool fReadWrite, + [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Retrieves a property handler for a Shell item.Type: IUnknown*A pointer to the IUnknown interface of a Shell item that supports IShellItem.Windows XP: Use SHCreateShellItem to create the Shell item.Windows Vista: Use SHCreateItemFromIDList, SHCreateItemFromParsingName, SHCreateItemFromRelativeName, SHCreateItemInKnownFolder, or SHCreateItemWithParent to create the Shell item.Type: BOOLTRUE to retrieve a read/write property handler. FALSE to retrieve a read-only property handler.Type: IUnknown*Pointer to the IUnknown interface of a class factory object that supports ICreateObject.Type: REFIIDA reference to the IID of the interface to retrieve through ppv.Type: void**When this function returns successfully, contains the interface pointer requested in riid. This is typically IPropertyStore or IPropertyStoreCapabilities.Type: PSSTDAPIReturns S_OK if successful, or an error value otherwise.This function is supported in Windows XP as part of the Microsoft Windows Desktop Search (WDS) redistributable which includes IPropertyStore and supporting interfaces. For applications supported only on Windows Vista or later, we recommend that you use IShellItem2::GetPropertyStoreWithCreateObject instead of PSGetItemPropertyHandlerWithCreateObject because IShellItem2::GetPropertyStoreWithCreateObject provides a richer set of properties in the property store that is returned.This function is approximately equivalent to passing the GPS_HANDLERPROPERTIESONLY flag to IShellItem2::GetPropertyStoreWithCreateObject.The punkCreateObject parameter enables the creation of a property store in a different context than that of the caller. For instance, the ICreateObject implementation can cause the property store to be created in another process. This parameter is used only for property handlers that support it and that are registered underYou must initialize Component Object Model (COM) with CoInitialize or OleInitialize before you call PSGetItemPropertyHandlerWithCreateObject. COM must remain initialized for the lifetime of this object.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSGetItemPropertyHandlerWithCreateObject to obtain a property handler for an item. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetitempropertyhandlerwithcreateobject + // PSSTDAPI PSGetItemPropertyHandlerWithCreateObject( IUnknown *punkItem, BOOL fReadWrite, IUnknown *punkCreateObject, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "82e0aa15-b67c-4c0a-bafb-f1dc5f822aec")] + public static extern HRESULT PSGetItemPropertyHandlerWithCreateObject([MarshalAs(UnmanagedType.IUnknown)] object punkItem, [MarshalAs(UnmanagedType.Bool)] bool fReadWrite, + [MarshalAs(UnmanagedType.IUnknown)] object punkCreateObject, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Gets a value from serialized property storage by property name.Type: PCUSERIALIZEDPROPSTORAGEA pointer to an allocated buffer that contains the serialized properties. Call IPersistSerializedPropStorage::GetPropertyStorage to obtain the buffer.Type: DWORDThe size, in bytes, of the USERIALIZESPROPSTORAGE buffer pointed to by psps.Type: LPCWSTRA pointer to a null-terminated, Unicode string that contains the name of the property.Type: PROPVARIANT*When this function returns, contains the requested value.Type: PSSTDAPIReturns S_OK if successful, or an error value otherwise.This function is intended to be called if the calling application already has a serialized property storage and needs no more than a few properties from storage. If many properties need to be retrieved, performance can be enhanced by creating a memory property store by calling PSCreateMemoryPropertyStore, initializing the property store by calling IPersistSerializedPropStorage::SetPropertyStorage, and using INamedPropertyStore or IPropertyStore to retrieve the properties.Note that PSGetNamedPropertyFromPropertyStorage works only on serialized buffers created by the system implementation of IPersistSerializedPropStorage. You must first obtain a memory property store by calling PSCreateMemoryPropertyStore; that store can then create a serialized buffer using the IPersistSerializedPropStorage interface.Although SERIALIZEDPROPSTORAGE is an opaque serialized data structure whose format may change in the future, earlier formats will be supported on subsequent versions of Windows. Because the format is opaque, applications should use supported property storage APIs to access and manipulate the serialized buffer (see IPersistSerializedPropStorage and PSGetPropertyFromPropertyStorage).ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSGetNamedPropertyFromPropertyStorage to read a value from serialized property storage. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetnamedpropertyfrompropertystorage + // PSSTDAPI PSGetNamedPropertyFromPropertyStorage( PCUSERIALIZEDPROPSTORAGE psps, DWORD cb, LPCWSTR pszName, PROPVARIANT *ppropvar ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "bb4eedc0-9ef5-46f2-83e5-340b77b3d876")] + public static extern HRESULT PSGetNamedPropertyFromPropertyStorage(IntPtr psps, uint cb, [MarshalAs(UnmanagedType.LPWStr)] string pszName, PROPVARIANT ppropvar); + + /// Gets an instance of a property description interface for a specified property name.Type: LPCWSTRA pointer to a null-terminated, Unicode string that identifies the property.Type: REFIIDReference to the interface ID of the requested property.Type: void**When this function returns, contains the interface pointer requested in riid. This is typically IPropertyDescription, IPropertyDescriptionAliasInfo, or IPropertyDescriptionSearchInfo.Type: PSSTDAPIReturns one of the following values.Return codeDescription S_OK The interface was obtained. E_INVALIDARG The pszCanonicalName parameter is NULL. TYPE_E_ELEMENTNOTFOUND The canonical name does not exist in the schema subsystem cache.It is recommended that you use the IID_PPV_ARGS macro, defined in objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, eliminating the possibility of a coding error.We recommend that pszCanonicalName point to the canonical name of a property, for example, . The canonical name is case sensitive.In addition to the new canonical names, callers can pass a legacy name for a property. The following table contains the complete list of supported legacy names and the canonical names they correspond to.Property nameMaps to propertyAccessSystem.DateAccessedAlbumSystem.Music.AlbumTitleAllocSizeSystem.FileAllocationSizeApertureSystem.Photo.ApertureArtistSystem.Music.ArtistAttribSystem.FileAttributesAttributesSystem.FileAttributesAttributesDescriptionSystem.FileAttributesDisplayAudio FormatSystem.Audio.FormatAudio Sample SizeSystem.Audio.SampleSizeBitDepthSystem.Image.BitDepthBitrateSystem.Audio.EncodingBitrateCameraModelSystem.Photo.CameraModelCapacitySystem.CapacityChannelsSystem.Audio.ChannelCountColorSpaceSystem.Image.ColorSpaceCompanySystem.CompanyCompressionSystem.Video.CompressionCompressionSystem.Video.CompressionCopyrightSystem.CopyrightCopyrightSystem.CopyrightCopyrightSystem.Image.CopyrightCreateSystem.DateCreatedCSCStatusSystem.OfflineStatusData RateSystem.Video.EncodingBitrateDateDeletedSystem.Recycle.DateDeletedDeletedFromSystem.Recycle.DeletedFromDimensionsSystem.Image.DimensionsDirectorySystem.ItemFolderNameDisplayDistanceSystem.Photo.SubjectDistanceDocAppNameSystem.ApplicationNameDocAuthorSystem.AuthorDocByteCountSystem.Document.ByteCountDocCategorySystem.CategoryDocCharCountSystem.Document.CharacterCountDocCommentsSystem.CommentDocCompanySystem.CompanyDocCreatedTmSystem.Document.DateCreatedDocEditTimeSystem.Document.TotalEditingTimeDocHiddenCountSystem.Document.HiddenSlideCountDocKeywordsSystem.KeywordsDocLastAuthorSystem.Document.LastAuthorDocLastPrintedSystem.Document.DatePrintedDocLastSavedTmSystem.Document.DateSavedDocLineCountSystem.Document.LineCountDocManagerSystem.Document.ManagerDocNoteCountSystem.Document.NoteCountDocPageCountSystem.Document.PageCountDocParaCountSystem.Document.ParagraphCountDocPresentationTargetSystem.Document.PresentationFormatDocRevNumberSystem.Document.RevisionNumberDocSlideCountSystem.Document.SlideCountDocSubjectSystem.SubjectDocTemplateSystem.Document.TemplateDocTitleSystem.TitleDocWordCountSystem.Document.WordCountDRM DescriptionSystem.DRM.DescriptionDurationSystem.Media.DurationEquipMakeSystem.Photo.CameraManufacturerExposureBiasSystem.Photo.ExposureBiasExposureProgSystem.Photo.ExposureProgramExposureTimeSystem.Photo.ExposureTimeFaxCallerIDSystem.Fax.CallerIDFaxCSIDSystem.Fax.CSIDFaxRecipientNameSystem.Fax.RecipientNameFaxRecipientNumberSystem.Fax.RecipientNumberFaxRoutingSystem.Fax.RoutingFaxSenderNameSystem.Fax.SenderNameFaxTimeSystem.Fax.TimeFaxTSIDSystem.Fax.TSIDFileDescriptionSystem.FileDescriptionFileSystemSystem.Volume.FileSystemFileTypeSystem.Image.FileTypeFileVersionSystem.FileVersionFlashSystem.Photo.FlashFlashEnergySystem.Photo.FlashEnergyFNumberSystem.Photo.FNumberFocalLengthSystem.Photo.FocalLengthFrame RateSystem.Video.FrameRateFrameCountSystem.Media.FrameCountFreeSpaceSystem.FreeSpaceGenreSystem.Music.GenreImageXSystem.Image.HorizontalSizeImageYSystem.Image.VerticalSizeISOSpeedSystem.Photo.ISOSpeedLightSourceSystem.Photo.LightSourceLinksUpToDateSystem.Document.LinksDirtyLinkTargetSystem.Link.TargetParsingPathLyricsSystem.Music.LyricsManagerSystem.Document.ManagerMeteringModeSystem.Photo.MeteringModeMMClipCountSystem.Document.MultimediaClipCountNameSystem.ItemNameDisplayOwnerSystem.FileOwnerPlay CountSystem.DRM.PlayCountPlay ExpiresSystem.DRM.DatePlayExpiresPlay StartsSystem.DRM.DatePlayStartsPresentationTargetSystem.Document.PresentationFormatProductNameSystem.Software.ProductNameProductVersionSystem.Software.ProductVersionProjectSystem.Media.ProjectProtectedSystem.DRM.IsProtectedRankSystem.Search.RankRatingSystem.RatingResolutionXSystem.Image.HorizontalResolutionResolutionYSystem.Image.VerticalResolutionSample RateSystem.Audio.SampleRateScaleSystem.Document.ScaleShutterSpeedSystem.Photo.ShutterSpeedSizeSystem.SizeSoftwareSystem.SoftwareUsedStatusSystem.Media.StatusStatusSystem.StatusStream NameSystem.Video.StreamNameSyncCopyInSystem.Sync.CopyInTrackSystem.Music.TrackNumberTypeSystem.ItemTypeTextVideo Sample SizeSystem.Video.SampleSizeWhenTakenSystem.Photo.DateTakenWriteSystem.DateModifiedYearSystem.Media.YearExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSGetPropertyDescriptionByName to retrieve the description for the ratings property. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetpropertydescriptionbyname + // PSSTDAPI PSGetPropertyDescriptionByName( LPCWSTR pszCanonicalName, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "181ebbfb-66ed-4763-ad2d-acf3c800f9d2")] + public static extern HRESULT PSGetPropertyDescriptionByName([MarshalAs(UnmanagedType.LPWStr)] string pszCanonicalName, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Gets an instance of a property description list interface for a specified property list.Type: LPCWSTRPointer to a null-terminated, Unicode string that identifies the property list. See IPropertySystem::GetPropertyDescriptionListFromString for more information about the format of this parameter.Type: REFIIDReference to the interface ID of the requested interface.Type: void**When this function returns, contains the interface pointer requested in riid. This is typically IPropertyDescriptionList.Type: PSSTDAPIReturns one of the following values.Return codeDescription S_OK The interface was obtained. E_INVALIDARG The ppv parameter is NULL. This function calls the property subsystem implementation of IPropertySystem::GetPropertyDescriptionListFromString to obtain a collection of properties provided as a semicolon-delimited property list string.We recommend that you use the IID_PPV_ARGS macro, defined in Objbase.h, to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding error.For more information about property schemas, see Property Schemas.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSGetPropertyDescriptionListFromString. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetpropertydescriptionlistfromstring + // PSSTDAPI PSGetPropertyDescriptionListFromString( LPCWSTR pszPropList, REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "348253ed-46ac-4643-bbf8-2d286ae97f07")] + public static extern HRESULT PSGetPropertyDescriptionListFromString([MarshalAs(UnmanagedType.LPWStr)] string pszPropList, [In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Gets the value of a property as stored in serialized property storage.Type: PCUSERIALIZEDPROPSTORAGEPointer to an allocated buffer that contains the serialized properties. This buffer is obtained by a call to IPersistSerializedPropStorage::GetPropertyStorage.Type: DWORDThe size, in bytes, of the USERIALIZESPROPSTORAGE buffer pointed to by psps.Type: REFPROPERTYKEYReference to the PROPERTYKEY that identifies the property for which to get the value.Type: PROPVARIANT**When this function returns, contains the requested value.Type: PSSTDAPIReturns S_OK if successful, or an error value otherwise.This function is intended to be called if the calling application already has a serialized property storage and needs no more than a few properties from storage. If many properties need to be retrieved, performance can be enhanced by creating a memory property store through PSCreateMemoryPropertyStore, initializing the property store by calling IPersistSerializedPropStorage::SetPropertyStorage, and by using IPropertyStore to retrieve the properties.Note that PSGetPropertyFromPropertyStorage works only on serialized buffers created by the system implementation of IPersistSerializedPropStorage. You must first obtain a memory property store by calling PSCreateMemoryPropertyStore. That store can then create a serialized buffer using the IPersistSerializedPropStorage interface.Although SERIALIZEDPROPSTORAGE is an opaque serialized data structure whose format may change in the future, earlier formats will be supported on subsequent versions of Windows. Because the format is opaque, applications should use supported property storage APIs to access and manipulate the serialized buffer (see IPersistSerializedPropStorage).ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSGetPropertyFromPropertyStorage to read a value from serialized property storage. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetpropertyfrompropertystorage + // PSSTDAPI PSGetPropertyFromPropertyStorage( PCUSERIALIZEDPROPSTORAGE psps, DWORD cb, REFPROPERTYKEY rpkey, PROPVARIANT *ppropvar ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "c649d25d-7971-4804-a5a2-3fd6860659b4")] + public static extern HRESULT PSGetPropertyFromPropertyStorage(IntPtr psps, uint cb, [In, MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY rpkey, PROPVARIANT ppropvar); + + /// Gets an instance of the subsystem object that implements IPropertySystem.Type: REFIIDReference to the IID of the requested interface.Type: void**When this function returns, contains the interface pointer requested in riid. This is typically IPropertySystem.Type: PSSTDAPIReturns one of the following values.Return codeDescription S_OK The interface was obtained. E_INVALIDARG The ppv parameter is NULL. You must initialize Component Object Model (COM) with CoInitialize or OleInitialize prior to calling PSGetPropertySystem. COM must remain initialized for the lifetime of this object. The property system object aggregates the free-threaded marshaller and is thread-safe.We recommend that you use the IID_PPV_ARGS macro defined in Objbase.h to package the riid and ppv parameters. This macro provides the correct IID based on the interface pointed to by the value in ppv, which eliminates the possibility of a coding error.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSGetPropertySystem. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetpropertysystem + // PSSTDAPI PSGetPropertySystem( REFIID riid, void **ppv ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "ddbf7cea-b22f-4cf9-8b5f-804640086466")] + public static extern HRESULT PSGetPropertySystem([In, MarshalAs(UnmanagedType.LPStruct)] Guid riid, [MarshalAs(UnmanagedType.Interface)] out object ppv); + + /// Gets a property value from a property store.Type: IPropertyStore*Pointer to an instance of the IPropertyStore interface, which represents the property store from which to get the value.Type: IPropertyDescription*Pointer to an instance of the IPropertyDescription interface, which represents the property in the property store.Type: PROPVARIANT*Pointer to an uninitialized PROPVARIANT structure. When this function returns, points to the requested property value.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.This helper function is used to read a property value from a store. If the calling code already has a PROPERTYKEY structure, it might be simpler to call IPropertyStore::GetValue directly.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSGetPropertyValue. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psgetpropertyvalue + // PSSTDAPI PSGetPropertyValue( IPropertyStore *pps, IPropertyDescription *ppd, PROPVARIANT *ppropvar ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "9369dc85-b006-4b30-a25e-58d53b76f334")] + public static extern HRESULT PSGetPropertyValue(IPropertyStore pps, IPropertyDescription ppd, PROPVARIANT ppropvar); + + /// Gets the class identifier (CLSID) of a per-computer, registered file property handler.Type: PCWSTRPointer to a null-terminated, Unicode buffer that contains the absolute path of the file whose property handler CLSID is requested.Type: CLSID*When this function returns, contains the requested property handler CLSID.Type: PSSTDAPIReturns S_OK if successful, or an error value otherwise.For information on how to register your handler, see Initializing Property Handlers.This function returns only those handlers registered under HKEY_LOCAL_MACHINE.Most calling applications should not need to call this method or use CoCreateInstance to create a property handler directly. Instead, calling applications should use IShellItem2::GetPropertyStore to create a property store for a Shell item on Windows Vista. IShellItem2::GetPropertyStore provides the largest set of available properties for a Shell item, and the most options for customizing exactly which properties to return.If no property handler is registered for the specified file, this function returns an error code. When this happens, it might still be possible to read certain file system properties from the property store returned from IShellItem2::GetPropertyStore.Applications that need to create a property handler from code and that must run both on Windows Vista and on Windows XP can call PSGetItemPropertyHandler to create a property store for a Shell item through the Microsoft Windows Desktop Search (WDS) redistributable.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSLookupPropertyHandlerCLSID. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pslookuppropertyhandlerclsid + // PSSTDAPI PSLookupPropertyHandlerCLSID( PCWSTR pszFilePath, CLSID *pclsid ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "43f90a33-9bd6-4e47-ab92-5e0d01ba268a")] + public static extern HRESULT PSLookupPropertyHandlerCLSID([MarshalAs(UnmanagedType.LPWStr)] string pszFilePath, out Guid pclsid); + + /// Converts a string to a PROPERTYKEY structure.Type: LPCWSTRPointer to a null-terminated, Unicode string to be converted.Type: PROPERTYKEY*When this function returns, contains a pointer to a PROPERTYKEY structure.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.The string to be converted must be formatted as . For instance, the string that corresponds to is: . PSStringFromPropertyKey outputs strings in this format.This function succeeds for any valid property key string, even if the property does not exist in the property schema.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSPropertyKeyFromString. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pspropertykeyfromstring + // PSSTDAPI PSPropertyKeyFromString( LPCWSTR pszString, PROPERTYKEY *pkey ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "9096912a-14ad-4a45-a564-08f98fce3f96")] + public static extern HRESULT PSPropertyKeyFromString([MarshalAs(UnmanagedType.LPWStr)] string pszString, out PROPERTYKEY pkey); + + /// Not supported.It is valid to call this function, but it is not implemented to perform any function so there is no reason to do so.Type: HRESULTReturns one of the following values.Return codeDescription S_OK Schema files reloaded. E_ACCESSDENIED The calling context does not have proper privileges. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psrefreshpropertyschema + // PSSTDAPI PSRefreshPropertySchema( ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "07efbf66-3594-4b9d-b959-278dc9000572")] + public static extern HRESULT PSRefreshPropertySchema(); + + /// Informs the schema subsystem of the addition of a property description schema file.Type: PCWSTRPointer to the full file path, as a Unicode string, to the property description schema (.propdesc) file on the local machine. This can be either a fully-specified full path, or a full path that includes environment variables such as .Type: HRESULTReturns one of the following values.Return codeDescription S_OK All property descriptions in the schema were registered. E_ACCESSDENIED The calling context does not have proper privileges. INPLACE_S_TRUNCATED One or more property descriptions in the schema failed to register. The specific failures are logged in the application event log.This function is a wrapper API for the schema subsystem's implementation of IPropertySystem::RegisterPropertySchema. Call this function only when the file is first installed on the computer. Typically, a setup application calls this function after it installs the .propdesc file, which should be stored in the install directory of the application under Program Files. Multiple calls can be made to IPropertySystem::RegisterPropertySchema in order to register multiple schema files.When registering property schema files, remember that they can be read by processes running as different users. Therefore, it is important to place a schema file in a location that grants read access to all users on the machine. Similarly, use the absolute path to the file in this function's pszPath parameter.Note Because schemas are specific to the machine and cannot be registered for each individual user, registering a file path under user profiles is not supported on Windows Vista.If a full or partial failure is encountered that prevents a property description from being loaded, the cause is recorded in the application event log. This function fails with E_ACCESSDENIED if the calling context does not have proper privileges, which includes write access to HKEY_LOCAL_MACHINE. It is the responsibility of the calling application to obtain privileges through User Account Control (UAC) mechanisms. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psregisterpropertyschema + // PSSTDAPI PSRegisterPropertySchema( PCWSTR pszPath ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "ea9c4361-fada-4b07-b450-dd0c6409745a")] + public static extern HRESULT PSRegisterPropertySchema([MarshalAs(UnmanagedType.LPWStr)] string pszPath); + + /// Sets the value of a property in a property store.Type: IPropertyStore*Pointer to an instance of the IPropertyStore interface, which represents the property store that contains the property.Type: IPropertyDescription*Pointer to an instance of the IPropertyDescription interface, which identifies the individual property.Type: REFPROPVARIANTReference to a PROPVARIANT structure that contains the new value.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.This helper function is used to write a property value to a store. If the calling code already has a PROPERTYKEY structure, it might be simpler to call IPropertyStore::SetValue directly.ExamplesThe following example, to be included as part of a larger program, demonstrates how to use PSSetPropertyValue. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-pssetpropertyvalue + // PSSTDAPI PSSetPropertyValue( IPropertyStore *pps, IPropertyDescription *ppd, REFPROPVARIANT propvar ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "b4f8c50d-93cd-4371-88b0-6ce58f023981")] + public static extern HRESULT PSSetPropertyValue(IPropertyStore pps, IPropertyDescription ppd, PROPVARIANT propvar); + + /// Creates a string that identifies a property from that property's key.Type: REFPROPERTYKEYReference to a PROPERTYKEY structure that identifies a property.Type: LPWSTRPointer to a buffer that receives the output string. The buffer should be large enough to contain PKEYSTR_MAX WCHARs.Type: UINTThe length of the buffer pointed to by psz, in WCHARs.Type: HRESULTIf this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.The string format retrieved is . For example, the output string for is .ExamplesThe following example, to be included as part of a larger program, demonstrates the use of PSPropertyKeyFromString. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psstringfrompropertykey + // PSSTDAPI PSStringFromPropertyKey( REFPROPERTYKEY pkey, LPWSTR psz, UINT cch ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "081f8e6d-9189-44f9-9b27-e85f4793da48")] + public static extern HRESULT PSStringFromPropertyKey([In, MarshalAs(UnmanagedType.LPStruct)] PROPERTYKEY pkey, [MarshalAs(UnmanagedType.LPWStr)] StringBuilder psz, uint cch); + + /// Informs the schema subsystem of the removal of a property description schema file.Type: PCWSTRPointer to the full file path, as a Unicode string, to the property description schema (.propdesc) file on the local machine. This can be either a fully-specified full path, or a full path that includes environment variables such as .Type: HRESULTReturns one of the following values.Return codeDescription S_OK The schema was unregistered. E_ACCESSDENIED The calling context does not have proper privileges.This function is a wrapper for the schema subsystem's implementation of IPropertySystem::UnregisterPropertySchema. Call this method when the file is being uninstalled from the computer. Typically, a setup application calls this method before or after uninstalling the .propdesc file. This method can be called after the file no longer exists.This function fails with a code of E_ACCESSDENIED if the calling context does not have proper privileges, which include write access to HKLM (HKEY_LOCAL_MACHINE). It is the responsibility of the calling application to obtain privileges through User Account Control (UAC) mechanisms. + // https://docs.microsoft.com/en-us/windows/desktop/api/propsys/nf-propsys-psunregisterpropertyschema + // PSSTDAPI PSUnregisterPropertySchema( PCWSTR pszPath ); + [DllImport(Lib.PropSys, SetLastError = false, ExactSpelling = true)] + [PInvokeData("propsys.h", MSDNShortId = "57df82a9-8954-4c2b-b794-82ac542149e2")] + public static extern HRESULT PSUnregisterPropertySchema([MarshalAs(UnmanagedType.LPWStr)] string pszPath); } } \ No newline at end of file