了解属性说明架构

本主题介绍 Shell 属性系统使用的属性说明架构。

Windows Vista 和更高版本的新功能的引入要求将现有 Shell 属性系统扩展到:

  • 支持丰富的可扩展属性描述系统,它提供有关属性的信息,包括显示名称、类型、显示类型、排序和组行为以及呈现和操作属性所需的其他属性。
  • 支持属性类型的库存列表 (与 UI 结合使用,这些类型可以在列表视图、预览窗格、属性对话框等不同视图中编辑这些类型,) 这些类型可与各种属性相关联。
  • 提供属性说明列表,用于定义各种视图中显示的属性集。
  • 提供简化的接口 IPropertyStore,以便可以更轻松地编写属性处理程序,以便将属性保存到文件中。
  • 支持非文件属性处理程序在视图中公开属性。

这些功能是在体系结构上实现的,该体系结构提供对 Shell 项属性的抽象访问。 此抽象称为 Shell 属性系统。

什么是属性说明架构?

架构子系统由以下各项组成:

  • 定义属性说明的一个或多个 .propdesc 架构文件。 属性说明架构是在系统上运行时使用 .propdesc 文件扩展名 () 在 XML 架构文件的集合中定义的。 当属性系统的一部分需要这些文件时,这些文件会延迟加载。
  • 用于存储已分析架构文件的内存中架构缓存,其中包括子系统引入的所有属性说明。 无需重新分析描述架构的 .propdesc 配置文件。 有关详细信息,请参阅 PSRegisterPropertySchemaPSUnregisterPropertySchemaPSRefreshPropertySchema
  • 实现 IPropertySystem 的子系统对象,用于获取或处理属性说明。
  • 实现 IPropertyDescription 的子系统对象,该对象用于根据属性说明通知和操作。
  • 实现 IPropertyDescriptionList 的子系统对象,该列表用作属性说明的集合。

注意

必须添加到 xmlns=http://schemas.microsoft.com/windows/2006/propertydescription .propdesc 文件的根架构元素。

 

为何使用架构?

属性本身不是类型安全的。 组件可以将数值分配给 System.Author 属性,或向 System 分配 FILETIME 日期戳。音乐。AlbumTitle 属性,并且,如果没有进一步的强制或指导,属性存储将允许它。 因此,我们需要一个概念来“架构化”属性,这让我们来到架构子系统。

什么是主要架构部件?

Shell 属性系统使用的属性说明架构由单个 propertyDescriptionList 元素以及 一个 schemaVersion 属性组成,该属性指示此架构定义格式的版本。 注意:值必须为“1.0”。

<!-- schema -->
    <xs:element name="schema">
      <xs:complexType>
        <xs:sequence>
          <xs:element ref="propertyDescriptionList" minOccurs="1" maxOccurs="1"/>
        </xs:sequence>
        <xs:attribute name="schemaVersion"  type="xs:string"/>
      </xs:complexType>
    </xs:element>

propertyDescriptionList 由一个或多个 propertyDescription 元素以及发布者和产品属性组成。

<!-- propertyDescriptionList -->
    <xs:element name="propertyDescriptionList">
      <xs:complexType>
        <xs:sequence>
          <xs:element ref="propertyDescription" minOccurs="1" maxOccurs="unbounded"/>
        </xs:sequence>
        <xs:attribute name="publisher" type="xs:string"/>
        <xs:attribute name="product"   type="xs:string"/>
      </xs:complexType>
    </xs:element>

propertyDescription 由一个 searchInfo 和零个或多个 labelInfo、typeInfodisplayInfo 元素以及 formatID、propIDpropstrname 属性组成。

对于要在系统中可用的每个唯一规范属性名称,应该有一个 propertyDescription 元素。 字符串属性的限制为 512 个字符。 超过 512 个字符的值将被截断。

<!-- propertyDescription -->
    <xs:element name="propertyDescription">
      <xs:complexType>
        <xs:all>
          <xs:element name="description"    type="xs:string" minOccurs="0" maxOccurs="1"/>
          <xs:element ref="searchInfo"   minOccurs="1" maxOccurs="1"/>
          <xs:element ref="labelInfo"    minOccurs="0" maxOccurs="1"/>
          <xs:element ref="typeInfo"     minOccurs="0" maxOccurs="1"/>
          <xs:element ref="displayInfo"  minOccurs="0" maxOccurs="1"/>
        </xs:all>
        <xs:attribute name="formatID"  type="upcase-uuid" use="required""/>
        <xs:attribute name="propID"    type="xs:nonNegativeInteger" use="required""/>
        <xs:attribute name="name"      type="canonical-name" use="required"/>
      </xs:complexType>
    </xs:element>

Windows 7 的更改

Windows 7 的属性说明架构已更改。 这些是非中断性变更。 如果 Windows 7 中不再支持属性元素或属性,Windows 7 操作系统将忽略 Windows Vista 元素或属性。 同样,Windows Vista 也会忽略 7 个属性元素或属性的新Windows。

但是,建议更新 Windows 7 的自定义属性,以便获得更一致的用户体验。

下面是新元素和属性:

以下元素和属性已更改:

已删除以下元素和属性:

propertyDescription

searchInfo

labelInfo

typeInfo

displayInfo

stringFormat

booleanFormat

numberFormat

dateTimeFormat

enumeratedList

drawControl

editControl

filterControl

queryControl

图像