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
C++UINT MsiQueryFeatureStateEx(
__in LPTSTR szProductCode,
__in LPTSTR szUserSid,
__in MSIINSTALLCONTEXT dwContext,
__in LPCTSTR szFeature,
__out_opt INSTALLSTATE *pdwState
);
Parameters
- szProductCode [in]
-
ProductCode GUID of the product that contains the feature of interest.
- szUserSid [in]
-
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.
Type of SID Meaning - NULL
NULL denotes the currently logged on user.
- User SID
Specifies enumeration for a particular user in the system. An example of user SID is "S-1-3-64-2415071341-1358098788-3127455600-2561".
Note The special SID string s-1-5-18 (system) cannot be used to enumerate features of products installed as per-machine. If dwContext is MSIINSTALLCONTEXT_MACHINE, szUserSid must be null.
- dwContext [in]
-
The installation context of the product instance being queried.
Name Meaning - MSIINSTALLCONTEXT_USERMANAGED
Retrieves the feature state for the per-user-managed instance of the product.
- MSIINSTALLCONTEXT_USERUNMANAGED
Retrieves the feature state for the per-user-unmanaged instance of the product.
Note 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.
- MSIINSTALLCONTEXT_MACHINE
Retrieves the feature state for the per-machine instance of the product.
- szFeature [in]
-
Specifies the feature being queried. Identifier of the feature as found in the Feature column of the Feature table.
- pdwState [out, optional]
-
Installation state of the feature for the specified product instance. This parameter can return one of the following or null.
Value Meaning - INSTALLSTATE_ADVERTISED
This feature is advertised.
- INSTALLSTATE_LOCAL
The feature is installed locally.
- INSTALLSTATE_SOURCE
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.
Windows Installer 2.0: Not supported. The MsiQueryFeatureStateEx function is available beginning with Windows Installer 3.0.
Requirements
Version | Windows 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 3.0 or later 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. |
---|---|
Header | Msi.h |
Library | Msi.lib |
DLL | Msi.dll |
Unicode and ANSI names | MsiQueryFeatureStateExW (Unicode) and MsiQueryFeatureStateExA (ANSI) |
See Also
Send comments about this topic to Microsoft
Build date: 8/13/2009
© 2009 Microsoft Corporation. All rights reserved.