共用方式為


msiSetComponentStateA 函式 (msiquery.h)

MsiSetComponentState 函式會將元件設定為要求的狀態。

語法

UINT MsiSetComponentStateA(
  [in] MSIHANDLE    hInstall,
  [in] LPCSTR       szComponent,
  [in] INSTALLSTATE iState
);

參數

[in] hInstall

處理提供給 DLL 自定義動作的安裝,或透過 MsiOpenPackageMsiOpenPackageExMsiOpenProduct 取得。

[in] szComponent

指定元件的名稱。

[in] iState

指定要設定的狀態。 此參數可以是下列其中一個值。

意義
INSTALLSTATE_ABSENT
元件已卸載。
INSTALLSTATE_LOCAL
元件已安裝在本機磁碟驅動器上。
INSTALLSTATE_SOURCE
元件會從來源、CD 或網路執行。

傳回值

MsiSetComponentState 函式會傳回下列值:

備註

MsiSetComponentState 函式會要求變更 Component 數據表中記錄的 Action 狀態。

如需詳細資訊,請參閱 從程式呼叫資料庫函式

如果函式失敗,您可以使用 MsiGetLastErrorRecord 取得擴充錯誤資訊。

注意

msiquery.h 標頭會根據 UNICODE 預處理器常數的定義,將 MsiSetComponentState 定義為別名,自動選取此函式的 ANSI 或 Unicode 版本。 混合使用編碼中性別名與非編碼中性的程序代碼,可能會導致編譯或運行時間錯誤不符。 如需詳細資訊,請參閱 函式原型的慣例

規格需求

需求
最低支援的用戶端 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
目標平台 Windows
標頭 msiquery.h
程式庫 Msi.lib
Dll Msi.dll

另請參閱

安裝程式選取函式