MsiGetComponentStateA 函式 (msiquery.h)

MsiGetComponentState 函式會取得元件的狀態。

語法

UINT MsiGetComponentStateA(
  [in]  MSIHANDLE    hInstall,
  [in]  LPCSTR       szComponent,
  [out] INSTALLSTATE *piInstalled,
  [out] INSTALLSTATE *piAction
);

參數

[in] hInstall

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

[in] szComponent

以 Null 結尾的字串,指定產品內的元件名稱。

[out] piInstalled

接收目前的已安裝狀態。 此參數不得為 null。 此參數可以是下列其中一個值。

意義
INSTALLSTATE_ABSENT
未安裝元件。
INSTALLSTATE_DEFAULT
元件會安裝在預設位置:本機或來源。
INSTALLSTATE_LOCAL
元件會安裝在本機磁碟驅動器上。
INSTALLSTATE_REMOVED
正在移除元件。 處於動作狀態且無法設定。
INSTALLSTATE_SOURCE
元件會從來源、CD-ROM 或網路執行。
INSTALLSTATE_UNKNOWN
無法辨識的產品或功能名稱已傳遞至函式。

[out] piAction

接收安裝期間所採取的動作。 此參數不得為 null。 如需傳回值,請參閱 piInstalled

傳回值

MsiGetComponentState 函式會傳回下列值:

備註

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

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

注意

msiquery.h 標頭會根據 UNICODE 預處理器常數的定義,將 MsiGetComponentState 定義為別名,自動選取此函式的 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

另請參閱

安裝程式選取函式

傳遞 Null 作為 Windows Installer 函式的自變數