MsiEnumProducts Function

Windows Installer

MsiEnumProducts Function

The MsiEnumProducts function enumerates through all the products currently advertised or installed. Products that are installed in both the per-user and per-machine installation context and advertisements are enumerated.

Syntax

C++UINT MsiEnumProducts(
  __in   DWORD iProductIndex,
  __out  LPTSTR lpProductBuf
);

Parameters

iProductIndex [in]

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

lpProductBuf [out]

Pointer to a buffer that receives the product 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 products 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 products, an application should initially call the MsiEnumProducts function with the iProductIndex parameter set to zero. The application should then increment the iProductIndex parameter and call MsiEnumProducts until there are no more products (until the function returns ERROR_NO_MORE_ITEMS).

When making multiple calls to MsiEnumProducts to enumerate all of the products, each call should be made from the same thread.

Requirements

VersionWindows Installer 5.0 on 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, Windows XP, and Windows 2000. See the Windows Installer Run-Time Requirements for information about the minimum Windows service pack that is required by a Windows Installer version.
HeaderMsi.h
LibraryMsi.lib
DLLMsi.dll
Unicode and ANSI namesMsiEnumProductsW (Unicode) and MsiEnumProductsA (ANSI)

See Also

System Status Functions
Determining Installation Context

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.