Share via


Installer.ProvideComponent 方法

Installer物件的ProvideComponent方法會傳回完整的元件路徑,並執行任何必要的安裝。 如有必要,Installer物件的ProvideComponent方法會提示來源,並遞增功能的使用計數。

語法

Installer.ProvideComponent(
  Product,
  Feature,
  Component,
  InstallMode
)

參數

產品

指定產品的產品代碼。

功能

指定包含元件之功能的功能識別碼。

元件

指定元件程式碼。

InstallMode

定義安裝模式。 此參數可以是下表所示的其中一個值。

名稱 意義
msiInstallModeDefault
0
視需要提供元件路徑,執行任何安裝。
msiInstallModeExisting
–1
只有在功能存在時,才提供元件路徑;否則,會傳回空字串。 此模式會驗證元件金鑰檔是否存在。
msiInstallModeNoDetection
–2
只有在功能存在時,才提供元件路徑。 否則,傳回空字串。 此模式會檢查元件的註冊,但不會驗證元件的金鑰檔是否存在。
msiInstallModeNoSourceResolution
–3
只有在具有 msiInstallStateLocal 的 InstallState參數存在時,才提供元件路徑。 這會檢查元件的註冊,但不會驗證元件的金鑰檔是否存在。
msiReinstallMode 旗標的組合
呼叫 ReinstallFeature 以針對 ReinstallMode 參數使用此參數重新安裝功能,然後提供元件。

 

傳回值

這個方法不會傳回值。

備註

ProvideComponent方法結合了UseFeature、ConfigureFeatureComponentPath的功能。 ProvideComponent方法可簡化呼叫順序,但它也會遞增使用量計數,且應謹慎使用,以防止不正確的使用量計數。 ProvideComponent方法也比先前提及的方法和屬性的一系列個別呼叫提供較少的彈性。

如果應用程式從非預期的情況復原,應用程式可能已經稱為 UseFeature 並遞增使用量計數。 在此情況下,應用程式應該呼叫 ConfigureFeature 方法,而不是 ProvideComponent 方法,以避免增加使用量計數。

msiInstallModeExisting 選項不能與 msiReinstallMode 旗標搭配使用。

規格需求

需求
版本
Windows Server 2012、Windows 8、Windows Server 2008 R2 或 Windows 7 上的 Windows Installer 5.0。 Windows Server 2008 或 Windows Vista 上的 Windows Installer 4.0 或 Windows Installer 4.5。 Windows Server 2003 或 Windows XP 上的 Windows Installer
DLL
Msi.dll
IID
IID_IInstaller定義為 000C1090-0000-0000-C000-000000000046

另請參閱

MsiProvideComponent