MsiLocateComponent Function

Windows Installer

MsiLocateComponent Function

The MsiLocateComponent function returns the full path to an installed component without a product code. This function attempts to determine the product using MsiGetProductCode, but is not guaranteed to find the correct product for the caller. MsiGetComponentPath should always be called when possible.

Syntax

C++INSTALLSTATE MsiLocateComponent(
  __in     LPCTSTR szComponent,
  __out    LPTSTR lpPathBuf,
  __inout  DWORD *pcchBuf
);

Parameters

szComponent [in]

Specifies the component ID of the component to be located.

lpPathBuf [out]

Pointer to a variable that receives the path to the component. The variable includes the terminating null character.

pcchBuf [in, out]

Pointer to a variable that specifies the size, in characters, of the buffer pointed to by the lpPathBuf parameter. On input, this is the full size of the buffer, including a space for a terminating null character. Upon success of the MsiLocateComponent function, the variable pointed to by pcchBuf contains the count of characters not including the terminating null character. If the size of the buffer passed in is too small, the function returns INSTALLSTATE_MOREDATA.

If lpPathBuf is null, pcchBuf can be null.

Return Value

Value Meaning
INSTALLSTATE_NOTUSED

The component being requested is disabled on the computer.

INSTALLSTATE_ABSENT

The component is not installed. See Remarks.

INSTALLSTATE_INVALIDARG

One of the function parameters is invalid.

INSTALLSTATE_LOCAL

The component is installed locally.

INSTALLSTATE_MOREDATA

The buffer provided was too small.

INSTALLSTATE_SOURCE

The component is installed to run from source.

INSTALLSTATE_SOURCEABSENT

The component source is inaccessible.

INSTALLSTATE_UNKNOWN

The product code or component ID is unknown. See Remarks.

 

Remarks

The MsiLocateComponent function might return INSTALLSTATE_ABSENT or INSTALL_STATE_UNKNOWN, for the following reasons:

  • INSTALLSTATE_ABSENT

    The application did not properly ensure that the feature was installed by calling MsiUseFeature and, if necessary, MsiConfigureFeature.

  • INSTALLSTATE_UNKNOWN

    The feature is not published. The application should have determined this earlier by calling MsiQueryFeatureState or MsiEnumFeatures. The application makes these calls while it initializes. An application should only use features that are known to be published. Since INSTALLSTATE_UNKNOWN should have been returned by MsiUseFeature as well, either MsiUseFeature was not called, or its return value was not properly checked.

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 namesMsiLocateComponentW (Unicode) and MsiLocateComponentA (ANSI)

See Also

Component-Specific Functions

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.