The MsiSetFeatureState function sets a feature to a specified state.
UINT MsiSetFeatureStateA( MSIHANDLE hInstall, LPCSTR szFeature, INSTALLSTATE iState );
Specifies the name of the feature.
Specifies the state to set. This parameter can be one of the following values.
||The feature is not installed.|
||The feature is installed on the local drive.|
||The feature is run from the source, CD, or network.|
||The feature is advertised.|
The MsiSetFeatureState function returns the following values:
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.
|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|