共用方式為


使用並存元件

使用下列程式來開發新的應用程式,或更新現有的應用程式,以使用 Microsoft 或其他並存元件發行者提供的 並存元件 。 如需目前由 Microsoft 提供的並存元件清單,請參閱 支援的 Microsoft 並存元件。 請注意,應用程式至少必須在 Windows XP 上執行,才能將元件安裝為並存元件。 如需詳細資訊,請參閱 建立並存元件指導方針

將並存元件新增至應用程式

  1. 識別應用程式所需的並存元件。 從 Windows XP 開始,這些並存元件及其元件資訊清單會隨作業系統一起安裝,但未全域註冊。

  2. 使用 XML 編輯器來建立 應用程式資訊清單。 請參閱下面的範例應用程式資訊清單。 如需詳細資訊,請參閱資訊清單檔案參考中的應用程式資訊清單

  3. 在可唯一定義應用程式的應用程式資訊清單的 DEF-coNtext assemblyIdentity 子專案中輸入屬性值。 如需 DEF 內容 assemblyIdentity的詳細資訊,請參閱 應用程式資訊清單

  4. 如果元件包含任何相依元件,請在應用程式資訊清單的對應 REF 內容 assemblyIdentity 子項目中輸入屬性值。 如需 REF 內容 assemblyIdentity的詳細資訊,請參閱 應用程式資訊清單

    <dependentAssembly>
      <assemblyIdentity type="win32"
                        name="Microsoft.Windows.SampleAssembly"
                        version="6.0.0.0" processorArchitecture="x86"
                        publicKeyToken="a5aaf5ba15723d5"/>
    
  5. 您可以將應用程式資訊清單包含在應用程式的二進位可執行檔標頭檔中。

    在此情況下,也會將下列這一行新增至應用程式標頭檔:

    CREATEPROCESS\_MANIFEST\_RESOURCE\_ID RT\_MANIFEST 「YourApp.exe.manifest」

    或者,您可以將個別的資訊清單檔放在與應用程式可執行檔相同的目錄中。 作業系統會先從檔案系統載入資訊清單,然後檢查可執行檔的資源區段。 檔案系統版本優先。

  6. 應該使用Windows Installer 2.0 版來安裝共用元件。 撰寫 Windows Installer 套件,如 如何安裝 Win32 元件以在 Windows XP 上並存共用?所述

  7. 您可以使用Windows Installer 2.0 版來安裝私人元件。 撰寫 Windows Installer 套件,如 如何安裝 Win32 元件,以在 Windows XP 上私人使用應用程式?所述。 您也可以使用任何其他安裝程式,將私人元件及其資訊清單複製到與應用程式可執行檔相同的資料夾中。

  8. 測試您的應用程式以確保結果。 請注意,您的測試電腦不應該註冊並存元件。

  9. 將您的應用程式或更新部署為 Windows Installer 套件。

範例應用程式資訊清單

以下是應用程式資訊清單的範例:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
  <assemblyIdentity type="win32" name="Microsoft.Windows.mysampleapp" version="1.0.0.0" processorArchitecture="x86"/>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Windows.SampleAssembly" version="6.0.0.0" processorArchitecture="x86" publicKeyToken="a5aaf5ba15723d5"/>
    </dependentAssembly>
  </dependency>
  <dependency>
    <dependentAssembly>
      <assemblyIdentity type="win32" name="Microsoft.Tools.MyPrivateDll" version="2.5.0.0" processorArchitecture="x86"/>
    </dependentAssembly>
  </dependency>
</assembly>