Microsoft KB Archive/228504

{|
 * width="100%"|

BUG: Skip Member Function of the IEnumVARIANT Interface Returns Incorrect Values

 * }

Q228504

-

The information in this article applies to:


 * Microsoft Win32 Software Development Kit (SDK)

-

SYMPTOMS
The default implementation of IEnumVARIANT::Skip for objects created by the Active Accessibility component is incorrect and returns:

S_OK if not at the end of the enumeration

or

S_FALSE if at the end of the enumeration

These messages are returned regardless of whether it skipped the number requested or not. This is inconsistent with the documented behavior of IEnumVARIANT::Skip which would only return S_OK if the specified number of elements were skipped.

This problem affects objects created by Oleacc.dll on behalf of system controls and user interface elements and common controls.

STATUS
This behavior is by design.

MORE INFORMATION
The return values of IEnumVARIANT::Skip( unsigned long celt ) are documented as:

S_OK if the number of elements skipped is equal to celt, and

S_FALSE if the number of elements skipped is fewer than celt.

This function is internally called by the AccessibleChildren function. But the AccessibleChildren function handles the odd return values and the Skip function works fine internally. If this function is called externally, which is not recommended, then the oddity in the return value should be noted.

To avoid problems when dealing with IEnumVARIANT, it is recommended that Skip function is not used and AccessibleChildren function with a non-zero iChildStart value is not called. Instead, use the AccessibleChildren with an iChildStart of 0 to get all the children, or use IEnumVARIANT::Next to retrieve them one by one (or in chunks), and manually skip over the ones that are not needed. VariantClear must be called to clear the unused variants.