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.
INSTALLSTATE MsiLocateComponentA( LPCSTR szComponent, LPSTR lpPathBuf, LPDWORD pcchBuf );
Specifies the component ID of the component to be located.
Pointer to a variable that receives the path to the component. The variable includes the terminating null character.
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.
||The component being requested is disabled on the computer.|
||The component is not installed. See Remarks.|
||One of the function parameters is invalid.|
||The component is installed locally.|
||The buffer provided was too small.|
||The component is installed to run from source.|
||The component source is inaccessible.|
||The product code or component ID is unknown. See Remarks.|
The MsiLocateComponent function might return INSTALLSTATE_ABSENT or INSTALL_STATE_UNKNOWN, for the following reasons:
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.
|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.|