MsiQueryFeatureStateExA function (msi.h)
The MsiQueryFeatureStateEx function returns the installed state for a product feature. This function can be used to query any feature of an instance of a product installed under the machine account or any context under the current user account or the per-user-managed context under any user account other than the current user. A user must have administrative privileges to get information for a product installed for a user other than the current user.
Syntax
UINT MsiQueryFeatureStateExA(
[in] LPCSTR szProductCode,
[in] LPCSTR szUserSid,
[in] MSIINSTALLCONTEXT dwContext,
[in] LPCSTR szFeature,
[out, optional] INSTALLSTATE *pdwState
);
Parameters
[in] szProductCode
ProductCode GUID of the product that contains the feature of interest.
[in] szUserSid
Specifies the security identifier (SID) of the account, under which, the instance of the product being queried exists. If dwContext is not MSIINSTALLCONTEXT_MACHINE, a null value specifies the current user.
[in] dwContext
The installation context of the product instance being queried.
[in] szFeature
Specifies the feature being queried. Identifier of the feature as found in the Feature column of the Feature table.
[out, optional] pdwState
Installation state of the feature for the specified product instance. This parameter can return one of the following or null.
Value | Meaning |
---|---|
|
This feature is advertised. |
|
The feature is installed locally. |
|
The feature is installed to run from source. |
Return value
The MsiQueryFeatureStateEx function returns the following values.
Value | Meaning |
---|---|
|
A user must have administrative privileges to get information for a product installed for a user other than the current user. |
|
The configuration data is corrupt. |
|
An invalid parameter was passed to the function. |
|
The function completed successfully. |
|
The feature ID does not identify a known feature. |
|
The product code does not identify a known product. |
|
An unexpected internal failure. |
For more information, see Displayed Error Messages.
Remarks
The MsiQueryFeatureStateEx function does not validate that the feature is actually accessible. The MsiQueryFeatureStateEx function does not validate the feature ID. ERROR_UNKNOWN_FEATURE is returned for any unknown feature ID. When the query is made on a product installed under the per-user-unmanaged context for a user account other than the current user, the function fails. In this case the function returns ERROR_UNKNOWN_FEATURE, or if the product is advertised only (not installed), ERROR_UNKNOWN_PRODUCT is returned.
Note
The msi.h header defines MsiQueryFeatureStateEx as an alias that 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 is 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. Windows Installer 4.0 or Windows Installer 4.5 on Windows Server 2008 or Windows Vista. 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 |