4.7 IEnumVARIANT Example

An application implementer can choose to implement IEnumVARIANT to expose a collection of homogeneous or heterogeneous data. Depending on the requirements of the application and the nature of the data exposed, the implementer can choose to implement the collection either as a static, semi-static, or dynamic server.

If the application exposes a rarely changing collection (such as the set of students that are enrolled in a specific class), it can do so by exposing a static IEnumVARIANT server.

If the application exposes data that might change more frequently, but that is meant to be read-only (such as statistics on a set of currently running processes), it can do so by exposing a semi-static IEnumVARIANT server.

If the application exposes data that changes frequently and that is to be as current as possible (such as the set of files from a folder), it can do so by exposing a dynamic IEnumVARIANT server.

In all the examples that follow, the client can use either the _NewEnum method or the QueryInterface method on the automation server object to get the IEnumVARIANT implementation.

In the examples, an array is maintained as a collection by the server, and the variable current shows the first position in the enumeration that has not yet been returned to the client (see section 3.3.1).

Show: