MsiGetComponentPathExW function (msi.h)
The MsiGetComponentPathEx function returns the full path to an installed component. If the key path for the component is a registry key then the function returns the registry key.
This function extends the existing MsiGetComponentPath function to enable searches for components across user accounts and installation contexts.
Syntax
INSTALLSTATE MsiGetComponentPathExW(
[in] LPCWSTR szProductCode,
[in] LPCWSTR szComponentCode,
[in, optional] LPCWSTR szUserSid,
[in, optional] MSIINSTALLCONTEXT dwContext,
[out, optional] LPWSTR lpOutPathBuffer,
[in, out, optional] LPDWORD pcchOutPathBuffer
);
Parameters
[in] szProductCode
A null-terminated string value that specifies an application's product code GUID. The function gets the path of installed components used by this application.
[in] szComponentCode
A null-terminated string value that specifies a component code GUID. The function gets the path of an installed component having this component code.
[in, optional] szUserSid
A null-terminated string value that specifies the security identifier (SID) for a user in the system. The function gets the paths of installed components of applications installed under the user accounts identified by this SID. The special SID string s-1-1-0 (Everyone) specifies all users in the system. If this parameter is NULL, the function gets the path of an installed component for the currently logged-on user only.
[in, optional] dwContext
A flag that specifies the installation context. The function gets the paths of installed components of applications installed in the specified installation context. This parameter can be a combination of the following values.
[out, optional] lpOutPathBuffer
A string value that receives the path to the component. This parameter can be NULL. If the component is a registry key, the registry roots are represented numerically. If this is a registry subkey path, there is a backslash at the end of the Key Path. If this is a registry value key path, there is no backslash at the end. For example, a registry path on a 32-bit operating system of HKEY_CURRENT_USER\SOFTWARE\Microsoft is returned as "01:\SOFTWARE\Microsoft". The registry roots returned on 32-bit operating systems are defined as shown in the following table.
Root | Meaning |
---|---|
|
00 |
|
01 |
|
02 |
|
03 |
[in, out, optional] pcchOutPathBuffer
Pointer to a location that receives the size of the buffer, in TCHAR, pointed to by the szPathBuf parameter. The value in this location should be set to the count of TCHAR in the string including the terminating null character. If the size of the buffer is too small, this parameter receives the length of the string value without including the terminating null character in the count.
Return value
The MsiGetComponentPathEx function returns the following values.
Value | Meaning |
---|---|
|
The component being requested is disabled on the computer. |
|
Configuration data is corrupt. |
|
The component is not installed. |
|
One of the function parameters is invalid. |
|
The component is installed locally. |
|
The component is installed to run from source. |
|
The component source is inaccessible. |
|
The product code or component ID is unknown. |
|
The component is corrupt or partially missing in some way and requires repair. |
Remarks
The MsiGetComponentPathEx 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.
Note
The msi.h header defines MsiGetComponentPathEx as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.
Requirements
Requirement | Value |
---|---|
Minimum supported client | Windows Installer 5.0 on Windows Server 2012, Windows 8, Windows Server 2008 R2 or Windows 7. See the Windows Installer Run-Time Requirements for information about the minimum Windows service pack that is required by a Windows Installer version. |
Target Platform | Windows |
Header | msi.h |
Library | Msi.lib |
DLL | Msi.dll |