MsiQueryComponentState Function

Windows Installer

MsiQueryComponentState Function

The MsiQueryComponentState function returns the installed state for a component. This function can query for a component of an instance of a product that is installed under user accounts other than the current user provided the product is not advertised under the per-user-unmanaged context for a user account other than the current user. The calling process must have administrative privileges to get information for a product installed for a user other than the current user.

Syntax

C++UINT MsiQueryComponentState(
  __in   LPTSTR szProductCode,
  __in   LPTSTR szUserSid,
  __in   MSIINSTALLCONTEXT dwContext,
  __in   LPCTSTR szComponent,
  __out  INSTALLSTATE *pdwState
);

Parameters

szProductCode [in]

Specifies the ProductCode GUID for the product that contains the component.

szUserSid [in]

Specifies the security identifier (SID) of the account under which the instance of the product being queried exists. If dwContext is not MSIINSTALLCONTEXT_MACHINE, null specifies the current user.

Type of SID Meaning
NULL

NULL denotes the currently logged on user.

User SID

Specifies enumeration for a particular user in the system. An example of user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561".

 

Note  The special SID string s-1-5-18 (system) cannot be used to enumerate products installed as per-machine. If dwContext is MSIINSTALLCONTEXT_MACHINE, szUserSid must be null.

dwContext [in]

The installation context of the product instance being queried.

Name Meaning
MSIINSTALLCONTEXT_USERMANAGED

Retrieves the component's state for the per–user–managed instance of the product.

MSIINSTALLCONTEXT_USERUNMANAGED

Retrieves the component's state for the per–user–non-managed instance of the product.

MSIINSTALLCONTEXT_MACHINE

Retrieves the component's state for the per-machine instance of the product.

 

szComponent [in]

Specifies the component being queried. Component code GUID of the component as found in the ComponentID column of the Component table.

pdwState [out]

Installation state of the component for the specified product instance. This parameter can return one of the following or null values.

Value Meaning
INSTALLSTATE_LOCAL

The component is installed locally.

INSTALLSTATE_SOURCE

The component is installed to run from the source.

 

Return Value

The MsiQueryComponentState function returns the following values.

Value Meaning
ERROR_ACCESS_DENIED

The calling process must have administrative privileges to get information for a product installed for a user other than the current user.

ERROR_BAD_CONFIGURATION

The configuration data is corrupt.

ERROR_INVALID_PARAMETER

An invalid parameter was passed to the function.

ERROR_SUCCESS

The function completed successfully.

ERROR_UNKNOWN_COMPONENT

The component ID does not identify a known component.

ERROR_UNKNOWN_PRODUCT

The product code does not identify a known product.

ERROR_FUNCTION_FAILED

Failures that cannot be ascribed to any Windows error code.

ERROR_MORE_DATA

Buffer too small to get the user SID.

 

For more information, see Displayed Error Messages.

Remarks

Windows Installer 2.0:  Not supported. The MsiQueryComponentState function is available beginning with Windows Installer 3.0.

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 3.0 or later 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 namesMsiQueryComponentStateW (Unicode) and MsiQueryComponentStateA (ANSI)

See Also

Component
Displayed Error Messages
Installer Selection Functions
ProductCode

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.