Export (0) Print
Expand All
Expand Minimize

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


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

ValueMeaning
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

Version

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.

Header

Msi.h

Library

Msi.lib

DLL

Msi.dll

Unicode and ANSI names

MsiLocateComponentW (Unicode) and MsiLocateComponentA (ANSI)

See also

Component-Specific Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft