共用方式為


註冊Device-Specific共同安裝程式

注意

通用或行動驅動程式套件不支援本節所述的功能。 請參閱 使用通用 INF 檔案

若要註冊裝置特定的共同安裝程式,請將下列區段新增至裝置的 INF 檔案:

;  :
;  :
[DestinationDirs]
XxxCopyFilesSection = 11                \\DIRID_SYSTEM
                                        \\ Xxx = driver or dev. prefix
;  :
;  :
[XxxInstall.OS-platform.CoInstallers]   \\ OS-platform is optional
CopyFiles = XxxCopyFilesSection
AddReg = Xxx.OS-platform.CoInstallers_AddReg
 
[XxxCopyFilesSection]
XxxCoInstall.dll
 
[Xxx.OS-platform.CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,"XxxCoInstall.dll, \
 XxxCoInstallEntryPoint"

DestinationDirs區段中的專案會指定XxxCopyFilesSection 中列出的檔案會複製到系統目錄。 例如,Xxx前置詞應該是驅動程式、裝置或 (裝置群組的唯一識別碼, cdrom_CopyFilesSection 例如) 。

上例中的 XxxInstall.OS-platform.CoInstallers 下一節是DDInstall。CoInstallers 區段。 本節的名稱可以有選擇性的 OS/架構擴充功能 (例如, cdrom_install.NTx86.CoInstallers) 。 它包含CopyFiles 指示詞,指定名為 XxxCopyFilesSectionfile-list-section,以及指定名為 Xxx.OS-platform.CoInstallers_AddRegadd-registry 區段AddReg 指示詞。

add-registry 區段中的專案會在裝置的驅動程式機碼中建立CoInstallers32值專案。 此專案包含共同安裝程式 DLL,並選擇性地包含特定的進入點。 如果您省略進入點,預設值為 CoDeviceInstall。 十六進位旗標參數 (0x00010000) 指定這是 REG_MULTI_SZ 值專案。

若要為裝置註冊多個裝置特定的共同安裝程式,請複製每個共同安裝程式的檔案,並在登錄專案中包含多個字串。 例如,若要註冊兩個共同安裝程式,請建立 INF 區段,如下所示:

;   :
;   :
[DestinationDirs]
XxxCopyFilesSection = 11                \\DIRID_SYSTEM
                                        \\ Xxx = driver or dev. prefix
;   :
;   :
[XxxInstall.OS-platform.CoInstallers]   \\ OS-platform is optional
CopyFiles = XxxCopyFilesSection
AddReg = Xxx.OS-platform.CoInstallers_AddReg
 
[XxxCopyFilesSection]
XxxCoInstall.dll                         \\ copy 1st coinst. file
YyyCoInstall.dll                         \\ copy 2nd coinst. file
 
[Xxx.OS-platform.CoInstallers_AddReg]
HKR,,CoInstallers32,0x00010000,                 \
    "XxxCoInstall.dll, XxxCoInstallEntryPoint", \
    "YyyCoInstall.dll, YyyCoInstallEntryPoint"
                                         \\ add both to registry

當處理[Linuxtallers INF] 區段時,會在安裝裝置的過程中註冊裝置特定的共同安裝程式。 接著,SetupAPI 會在安裝程式的每個後續步驟呼叫共同安裝程式。 如果為裝置註冊多個共同安裝程式,SetupAPI 會依照登錄中所列的順序呼叫它們。