com4:Extension

提供將 COM 註冊公開給應用程式套件外部用戶端的功能。 com4 擴充功能是舊版 COM 架構版本的超集和取代版本。 如需詳細資訊,請參閱<備註>一節。

元素階層

<套件>

    <應用程式>

         <應用程式>

              <擴充功能>

                   <com4:Extension>

Syntax

<com4:Extension
  Category = 'A string that can have one of the following values: "windows.comServer" or "windows.comInterface".'
  Executable = 'An optional string with a value between 1 and 256 characters in length that must end with ".exe" and cannot contain these characters: <, >, :, ", |, ?, or *.'
  EntryPoint = 'An optional string with a value between 1 and 256 characters in length that cannot start or end with a whitespace character.'
  RuntimeType = 'An optional string with a value between 1 and 255 characters in length that cannot start or end with a period or contain these characters: <, >, :, ", /, \, |, ?, or *.'
  StartPage = 'An optional string with a value between 1 and 256 characters in length that cannot contain these characters: <, >, :, ", |, ?, or *.'
  ResourceGroup = 'An optional alphanumeric string with a value between 1 and 255 characters in length. Must begin with a letter.'
  TrustLevel = 'An optional string the can have one of the following values: "appContainer" or "mediumIL".'
  RuntimeBehavior = 'An optional string the can have one of the following values: "windowsApp", "packagedClassicApp", or "win32App".'
  HostId = 'An optional alphanumeric string with a value between 1 and 255 characters in length. Must begin with a letter.'
  Parameters = 'An optional string with a value between 1 and 32767 characters in length with a non-whitespace character at its beginning and end.'
  uap11:Id = 'An optional string with a value between 1 and 255 characters in length with a non-whitespace character at its beginning and end.'
  uap11:Subsystem = 'An optional string that can have one of the following values: "console" or "windows".'
  uap11:SupportsMultipleInstances = 'An optional boolean value.'
  uap11:ResourceGroup = 'An optional alphanumeric string with a value between 1 and 255 characters in length. Must begin with a letter.'
  uap11:CurrentDirectoryPath = 'An optional string that cannot contain these characters: <, >, |, ?, or *. >'
  uap11:Parameters = 'An optional string with a value between 1 and 32767 characters in length with a non-whitespace character at its beginning and end.'
  desktop7:CompatMode = 'An optional string the can have one of the following values: "classic" or "modern".'
  desktop7:Scope = 'An optional string that can have one of the following values: "machine" or "user".' />

  <!-- Child elements -->
  com4:ComServer
  com4:ComInterface

</com4:Extension>

屬性和元素

屬性

屬性 描述 資料類型 必要 預設值
類別 應用程式擴充點的類型。 可以具有下列其中一個值的字串: windows.comServerwindows.comInterface Yes
可執行檔 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,會忽略此值。 長度介於 1 到 256 個字元之間的選擇性字串,其長度必須以 .exe 結尾,且不能包含下列字元:<、、|:>"? 或 。* No
EntryPoint 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,會忽略此值。 長度介於 1 到 256 個字元之間的選擇性字串,不能以空格符開頭或結尾。 No
RuntimeType 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,會忽略此值。 長度介於 1 到 255 個字元之間的選擇性字串,長度不能以句號開頭或結尾,或包含下列字元:<、、\:/|">? 或 。* No
StartPage 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,會忽略此值。 長度介於 1 到 256 個字元之間的選擇性字串,不能包含下列字元:<、、、>:"|?或 。* No
ResourceGroup 標記,可用來將擴充功能啟用群組在一起,以供資源管理之用 (例如 CPU 和記憶體) 。 您可以設定 ResourceGroup 的值是自由格式且有彈性的。 請參閱 Application@ResourceGroup 長度介於 1 到 255 個字元之間的選擇性英數位元字串。 必須以字母開頭。 No
uap10:TrustLevel 指定延伸模組的信任層級。 在目前版本中,com4 延伸模組不支援此屬性。 一律使用 “mediumIL” 值。 的選擇性字串可以有下列其中一個值: appContainermediumIL No
uap10:RuntimeBehavior 指定延伸模組的運行時間行為。 在目前版本中,com4 延伸模組不支援此屬性。 一律會使用 「packagedClassicApp」 值。 的選擇性字串可以有下列其中一個值: windowsApppackagedClassicAppwin32App No
uap10:HostId 這個值 指定擴充功能的主機運行時間標識碼。 長度介於 1 到 255 個字元之間的選擇性英數位元字串。 必須以字母開頭。 No
uap10:Parameters 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,會忽略此值。 長度介於 1 到 32767 個字元的選擇性字串,其開頭和結尾為非空格符。 No
uap11:Id 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,會忽略此值。 長度介於 1 到 255 個字元的選擇性字串,其開頭和結尾為非空格符。 No
uap11:子系統 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,會忽略此值。 可具有下列其中一個值的選擇性字串: 控制台視窗 No
uap11:SupportsMultipleInstances 指定實例是否應該在不同的進程中執行。 預設值為 false。 選擇性布爾值。 No
uap11:ResourceGroup 標記,可用來將擴充功能啟用群組在一起,以供資源管理之用 (例如 CPU 和記憶體) 。 您可以設定 ResourceGroup 的值是自由格式且有彈性的。 請參閱 Application@ResourceGroup 長度介於 1 到 255 個字元之間的選擇性英數位元字串。 必須以字母開頭。 No
uap11:CurrentDirectoryPath 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,會忽略此值。 此屬性支持宏。 如需詳細資訊,請參閱 套件指令清單架構中的宏 無法包含下列字元的選擇性字串:<、、、>|?*。 > No
uap11:Parameters 此屬性繼承自基底延伸模組語法,不適用於 com4 延伸模組。 除了語法驗證之外,也會忽略此值。 此屬性支持宏。 如需詳細資訊,請參閱 套件指令清單架構中的宏 長度介於 1 到 32767 個字元的選擇性字串,其開頭和結尾為非空格符。 No
desktop7:CompatMode 指定此延伸模組的資訊是以傳統方式向 Windows 註冊, (例如,透過登錄) 或以更具範圍的方式向 COM 註冊未封裝的應用程式註冊類型。 預設值為 「modern」。 CompatMode=“classic” 需要 Microsoft.classicAppCompat_8wekyb3d8bbwe 功能。 的選擇性字串可以有下列其中一個值: 傳統新式 No
desktop7:Scope 指定註冊是否只有以使用者身分註冊 (使用者) 執行的其他應用程式,或是否對 (計算機上的所有使用者和服務顯示註冊) 。 預設值為 「user」。 Scope=“machine” 需要 Microsoft.classicAppCompatElevated_8wekyb3d8bbwe 功能。 可具有下列其中一個值的選擇性字串: 計算機使用者 No

子元素

子項目 描述
com4:ComServer comServer 延伸模組可能包含類別註冊,包括實作這些類別的伺服器啟用詳細數據,以及 ProgId 和 TreatAsClass 註冊,以提供在運行時間參考這些類別的其他標識符。
com4:ComInterface 宣告 windows.comInterface (com4:ComInterface) 類型的套件延伸點。

父元素

子項目 描述
延伸模組 定義應用程式的一或多個擴充點。

備註

com4 延伸模組基本上是舊 windows.comServer/windows.comInterface 延伸模組語法的重寫。 此延伸模組是先前 com 延伸模組功能的超集,具有繼承語法的相同行為。 封裝中使用的新語法指令清單驗證,更符合延伸模組的語意需求。

  • 在舊版中,每個擴充功能都會被視為個別的文件,允許驗證非唯一索引鍵和浮點參考。
  • 在舊版中,如果重複的屬性出現在相同的延伸模塊實例中,則只有指令清單驗證才會攔截受限於唯一/索引鍵條件約束的屬性重複。 複製這些屬性的套件無法部署,但診斷資訊有限,無法識別問題。
  • 在舊版中,參考項位於不同延伸模塊實例的keyref會遭到指令清單驗證封鎖,這是相對於部署/運行時間行為支援的人工限制。

以 Windows 11 為目標的應用程式,其應該使用其所有 windows.comServer/windows.comInterface 延伸模組的新 com4 命名空間。 不建議將新的命名空間與較舊的命名空間混合,原因包括:

  • 在支援新命名空間的版本上部署套件將會處理來自所有命名空間的延伸模組,而使用不同命名空間版本在延伸模塊之間複製的任何唯一標識元將會導致失敗。 使用較舊的命名空間可防止指令清單驗證偵測這些錯誤。
  • 由於舊命名空間架構的限制,舊語法中的keyref無法參考新語法中的索引鍵,因為這些是擴充功能的不同實例。

使用下列 com4 語法語意具有功能需求:

  • CompatMode=“classic” 需要Microsoft.classicAppCompat_8wekyb3d8bbwe
  • Scope=“machine” 需要Microsoft.classicAppCompatElevated_8wekyb3d8bbwe

下列範例示範如何註冊同一類別的跨進程和同進程伺服器實作。

範例

<com4:Class Id="f4ed7720-9b3a-44a4-xxxx-xxxxxxxxxxxx" DisplayName="CLSID_Foo"/> 
<com:ExeServer Executable="MyServer.exe" DisplayName="My server">  
  <com4:ClassReference Id="f4ed7720-9b3a-44a4-xxxx-xxxxxxxxxxxx"/>  
</com:ExeServer> 
<com4:InProcessServer Path="MyServer.dll">  
  <com4:ClassReference Id="f4ed7720-9b3a-44a4-xxxx-xxxxxxxxxxxx"/>  
</com4:InProcessServer> 

com4 延伸模組中的新功能

  • 支援非受控和 Managed) 和自定義進程內處理程式 (非 OLE 預設處理程式) (。 這項功能目前受到原則限制的功能限制:
    • 這目前僅供具有外部位置的套件使用;因為安裝位置上的 ACL 導致套件無法在套件外部載入套件的 DLL,所以不適用於大部分的一般套件。 如需具有外部位置之套件的詳細資訊,請參閱 使用外部位置封裝來授與套件身分識別。
  • 現在可以建立 TypeLib 與類別註冊的關聯。

規格需求

Item
Namespace http://schemas.microsoft.com/appx/manifest/com/windows10/4
OS 最低版本 Windows 10 (組建 20348)