MsiEnumComponentsA function (msi.h)

The MsiEnumComponents function enumerates the installed components for all products. This function retrieves one component code each time it is called.

Syntax

UINT MsiEnumComponentsA(
  [in]  DWORD iComponentIndex,
  [out] LPSTR lpComponentBuf
);

Parameters

[in] iComponentIndex

Specifies the index of the component to retrieve. This parameter should be zero for the first call to the MsiEnumComponents function and then incremented for subsequent calls. Because components are not ordered, any new component has an arbitrary index. This means that the function can return components in any order.

[out] lpComponentBuf

Pointer to a buffer that receives the component code. This buffer must be 39 characters long. The first 38 characters are for the GUID, and the last character is for the terminating null character.

Return value

Value Meaning
ERROR_BAD_CONFIGURATION
The configuration data is corrupt.
ERROR_INVALID_PARAMETER
An invalid parameter was passed to the function.
ERROR_NO_MORE_ITEMS
There are no components to return.
ERROR_NOT_ENOUGH_MEMORY
The system does not have enough memory to complete the operation. Available with Windows Server 2003.
ERROR_SUCCESS
A value was enumerated.
 
 

Remarks

To enumerate components, an application should initially call the MsiEnumComponents function with the iComponentIndex parameter set to zero. The application should then increment the iComponentIndex parameter and call MsiEnumComponents until there are no more components (that is, until the function returns ERROR_NO_MORE_ITEMS).

When making multiple calls to MsiEnumComponents to enumerate all of the product's components, each call should be made from the same thread.

Note

The msi.h header defines MsiEnumComponents as an alias that 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 is 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. See the Windows Installer Run-Time Requirements for information about the minimum Windows service pack that is required by a Windows Installer version.
Target Platform Windows
Header msi.h
Library Msi.lib
DLL Msi.dll

See also

System Status Functions