MsiGetFeatureValidStates Function

Windows Installer

MsiGetFeatureValidStates Function

The MsiGetFeatureValidStates function returns a valid installation state.

Syntax

C++UINT MsiGetFeatureValidStates(
  __in   MSIHANDLE hInstall,
  __in   LPCTSTR szFeature,
  __out  DWORD *pInstallState
);

Parameters

hInstall [in]

Handle to the installation provided to a DLL custom action or obtained through MsiOpenPackage, MsiOpenPackageEx, or MsiOpenProduct.

szFeature [in]

Specifies the feature name.

pInstallState [out]

Receives the location to hold the valid installation states. For each valid installation state, the installer sets pInstallState to a combination of the following values. This parameter should not be null.

Decimal Value Meaning
2
INSTALLSTATE_ADVERTISED

The feature can be advertised.

4
INSTALLSTATE_ABSENT

The feature can be absent.

8
INSTALLSTATE_LOCAL

The feature can be installed on the local drive.

16
INSTALLSTATE_SOURCE

The feature can be configured to run from source, CD-ROM, or network.

32
INSTALLSTATE_DEFAULT

The feature can be configured to use the default location: local or source.

 

Return Value

The MsiGetFeatureValidStates function returns the following values:

ERROR_FUNCTION_FAILED

The function failed.

ERROR_INVALID_HANDLE

An invalid or inactive handle was supplied.

ERROR_INVALID_HANDLE_STATE

An invalid handle state was supplied.

ERROR_INVALID_PARAMETER

An invalid parameter was passed to the function.

ERROR_SUCCESS

The function succeeded.

ERROR_UNKNOWN_FEATURE

An unknown feature was requested.

Remarks

See Calling Database Functions From Programs.

The MsiGetFeatureValidStates function determines state validity by querying all components that are linked to the specified feature without taking into account the current installed state of any component.

The possible valid states for a feature are determined as follows:

  • If the feature does not contain components, both INSTALLSTATE_LOCAL and INSTALLSTATE_SOURCE are valid states for the feature.
  • If at least one component of the feature has an attribute of msidbComponentAttributesLocalOnly or msidbComponentAttributesOptional, INSTALLSTATE_LOCAL is a valid state for the feature.
  • If at least one component of the feature has an attribute of msidbComponentAttributesSourceOnly or msidbComponentAttributesOptional, INSTALLSTATE_SOURCE is a valid state for the feature.
  • If a file of a component that belongs to the feature is patched or from a compressed source, then INSTALLSTATE_SOURCE is not included as a valid state for the feature.
  • INSTALLSTATE_ADVERTISE is not a valid state if the feature disallows advertisement (msidbFeatureAttributesDisallowAdvertise) or the feature requires platform support for advertisement (msidbFeatureAttributesNoUnsupportedAdvertise) and the platform does not support it.
  • INSTALLSTATE_ABSENT is a valid state for the feature if its attributes do not include msidbFeatureAttributesUIDisallowAbsent.
  • Valid states for child features marked to follow the parent feature (msidbFeatureAttributesFollowParent) are based upon the parent feature's action or installed state.

After calling MsiGetFeatureValidStates a conditional statement may then be used to test the valid installation states of a feature. For example, the following call to MsiGetFeatureValidStates gets the installation state of Feature1.

MsiGetFeatureValidStates(hProduct, "Feature1", &dwValidStates);

If Feature1 has attributes of value 0 (favor local), and Feature1 has one component with attributes of value 0 (local only), the value of dwValidStates after the call is 14. This indicates that INSTALLSTATE_LOCAL, INSTALLSTATE_ABSENT,and INSTALLSTATE_ADVERTISED are valid states for Feature1. The following conditional statement evaluates to True if local is a valid state for this feature.

( ( dwValidStates & ( 1 << INSTALLSTATE_LOCAL ) ) == ( 1 << INSTALLSTATE_LOCAL ) )

If the function fails, you can obtain extended error information by using MsiGetLastErrorRecord.

Requirements

VersionWindows 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 on Windows Server 2003, Windows XP, and Windows 2000
HeaderMsiquery.h
LibraryMsi.lib
DLLMsi.dll
Unicode and ANSI namesMsiGetFeatureValidStatesW (Unicode) and MsiGetFeatureValidStatesA (ANSI)

See Also

Installer Selection Functions
Passing Null as the Argument of Windows Installer Functions

Send comments about this topic to Microsoft

Build date: 8/13/2009

© 2009 Microsoft Corporation. All rights reserved.