MsiGetComponentStateA function (msiquery.h)

The MsiGetComponentState function obtains the state of a component.

Syntax

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

Parameters

[in] hInstall

Handle to the installation provided to a DLL custom action or obtained through MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct.

[in] szComponent

A null-terminated string that specifies the component name within the product.

[out] piInstalled

Receives the current installed state. This parameter must not be null. This parameter can be one of the following values.

Value Meaning
INSTALLSTATE_ABSENT
The component is not installed.
INSTALLSTATE_DEFAULT
The component is installed in the default location: local or source.
INSTALLSTATE_LOCAL
The component is installed on the local drive.
INSTALLSTATE_REMOVED
The component is being removed. In action state and not settable.
INSTALLSTATE_SOURCE
The component runs from the source, CD-ROM, or network.
INSTALLSTATE_UNKNOWN
An unrecognized product or feature name was passed to the function.

[out] piAction

Receives the action taken during the installation. This parameter must not be null. For return values, see piInstalled.

Return value

The MsiGetComponentState function returns the following values:

Remarks

If the function fails, you can obtain extended error information by using MsiGetLastErrorRecord.

For more information, see Calling Database Functions From Programs.

Note

The msiquery.h header defines MsiGetComponentState as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.

Requirements

Requirement Value
Minimum supported client Windows Installer 5.0 on Windows Server 2012, Windows 8, Windows Server 2008 R2 or Windows 7. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. Windows Installer on Windows Server 2003 or Windows XP
Target Platform Windows
Header msiquery.h
Library Msi.lib
DLL Msi.dll

See also

Installer Selection Functions

Passing Null as the Argument of Windows Installer Functions