MsiSetFeatureStateA function (msiquery.h)
The MsiSetFeatureState function sets a feature to a specified state.
Syntax
UINT MsiSetFeatureStateA(
[in] MSIHANDLE hInstall,
[in] LPCSTR szFeature,
[in] INSTALLSTATE iState
);
Parameters
[in] hInstall
Handle to the installation provided to a DLL custom action or obtained through MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct.
[in] szFeature
Specifies the name of the feature.
[in] iState
Specifies the state to set. This parameter can be one of the following values.
Return value
The MsiSetFeatureState function returns the following values:
Remarks
The MsiSetFeatureState function requests a change in the select state of a feature in the Feature table and its children. In turn, the action state of all the components linked to the changed feature records are also updated appropriately, based on the new feature select state.
The MsiSetInstallLevel function must be called before calling MsiSetFeatureState.
When MsiSetFeatureState is called, the installer attempts to set the action state of each component tied to the specified feature to the specified state. However, there are common situations when the request cannot be fully implemented. For example, if a feature is tied to two components, component A and component B, through the FeatureComponents table, and component A has the msidbComponentAttributesLocalOnly attribute and component B has the msidbComponentAttributesSourceOnly attribute. In this case, if MsiSetFeatureState is called with a requested state of either INSTALLSTATE_LOCAL or INSTALLSTATE_SOURCE, the request cannot be fully implemented for both components. In this case, both components are turned ON, with component A set to Local and component B set to Source.
If more than one feature is linked to a single component (a common scenario), the final action state of that component is determined as follows:
- If at least one feature requires the component to be installed locally, the feature is installed with a state of local.
- If at least one feature requires the component to be run from the source, the feature is installed with a state of source.
- If at least one feature requires the removal of the component, the action state is absent.
If the function fails, you can obtain extended error information by using MsiGetLastErrorRecord.
Note
The msiquery.h header defines MsiSetFeatureState 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. 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 |
Target Platform | Windows |
Header | msiquery.h |
Library | Msi.lib |
DLL | Msi.dll |