瞭解屬性描述架構

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

Windows Vista 和更新版本的新功能引進需要將現有的 Shell 屬性系統擴充至:

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

這些功能可在提供殼層專案屬性抽象存取的架構上達成。 這個抽象概念稱為 Shell 屬性系統。

什麼是屬性描述架構?

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

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

注意

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

 

為何要使用架構?

屬性本身不是型別安全。 元件可以將數值指派給 System.Author 屬性,或 將 FILETIME 日期戳記指派給 System.Music.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元素所組成,以及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和零或一個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 也會忽略新的 Windows 7 屬性元素或屬性。

不過,建議更新 Windows 7 的自訂屬性,以取得更佳且更一致的使用者體驗。

以下是新的元素和屬性:

下列元素和屬性已變更:

已移除下列元素和屬性:

propertyDescription

searchInfo

labelInfo

typeInfo

displayInfo

stringFormat

booleanFormat

numberFormat

dateTimeFormat

enumeratedList

drawControl

editControl

filterControl

queryControl

image