共用方式為


瞭解屬性描述架構

本主題介紹Shell屬性系統所使用的屬性描述架構。

Windows Vista 及之後的版本引入的新功能需要擴充現有的 Shell 屬性系統。

  • 支援一個豐富且可擴充的屬性描述系統,提供屬性的相關資訊,包括顯示名稱、類型、顯示類型、排序和分組行為,以及呈現和操作這些屬性所需的其他屬性。
  • 支援屬性類型的庫存清單(結合UI,可在不同的檢視中編輯這些類型,例如 listview、預覽窗格、屬性對話框等等),這些類型可以與各種屬性相關聯。
  • 提供屬性描述清單,這些清單會定義各種檢視中顯示的屬性集。
  • 提供簡化的介面,IPropertyStore,因此可以更輕鬆地撰寫屬性處理程式,以便將屬性保存至檔案。
  • 支援非檔案屬性處理程式在檢視中公開屬性。

這些功能是透過一種允許抽象存取殼層項目屬性的架構實現的。 這個抽象概念稱為Shell屬性系統。

什麼是屬性描述架構?

架構子系統包含下列各項:

  • 一或多個定義屬性描述的 .propdesc 架構檔案。 屬性描述架構定義於系統的執行階段中的一組 XML 架構檔案(使用 .propdesc 擴展名)。 當屬性系統的一部分需要這些檔案時,這些檔案會延遲載入。
  • 記憶體內部架構快取,用來儲存剖析的架構檔案,其中包含子系統導入的所有屬性描述。 不需要重新剖析描述架構的 .propdesc 組態檔。 如需詳細資訊,請參閱 PSRegisterPropertySchemaPSUnregisterPropertySchemaPSRefreshPropertySchema
  • 實作 IPropertySystem的子系統物件,用來取得或處理屬性描述。
  • 實作 IPropertyDescription的子系統物件,用來根據屬性描述進行通知和操作。
  • 實作 IPropertyDescriptionList的子系統對象,這個物件會做為屬性描述的集合。

您必須將 xmlns=http://schemas.microsoft.com/windows/2006/propertydescription 新增至 .propdesc 檔案的根架構元素。

 

為何要使用架構?

屬性本身並不安全。 元件可以將數值指派給 System.Author 屬性,或將 FILETIME 日期戳記指派給 System.Music.AlbumTitle 屬性,而且如果沒有進一步強制執行或指引,屬性存放區就會允許它。 因此,我們需要一個概念來「架構化」屬性,這讓我們來到架構子系統。

什麼是主要架構元件?

Shell 屬性系統所使用的屬性描述架構是由單一 屬性描述列表 元素所組成,以及指出此架構定義格式版本的 架構版本 屬性。 注意:值必須是 “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 元素所組成,以及 publisherproduct 屬性。

<!-- 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 和零或一個 labelInfotypeInfodisplayInfo 元素所組成,以及 formatIDpropIDpropstrname 屬性。

系統中每個要被納入的唯一標準屬性名稱都應該有一個 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 也會忽略新的 Windows 7 屬性元素或屬性。

不過,建議更新 Windows 7 的自定義屬性,以取得較佳且更一致的用戶體驗。

以下是新的元素與屬性:

下列元素與屬性已變更:

已移除下列元素與屬性:

propertyDescription

searchInfo

labelInfo

typeInfo

displayInfo

stringFormat

布爾值格式

numberFormat

日期時間格式

列舉列表

drawControl

編輯控制

過濾控制

查詢控制

圖像