Voice-Menu Enumerator

When an application creates a new voice menu by using the IVoiceCmd::MenuCreate member function with the VCMDMC_CREATE_NEW, VCMDMC_CREATE_ALWAYS, or VCMDMC_OPEN_ALWAYS value, the voice-command object stores the new menu in a database. When the application is restarted at a later time, it can save time by loading menus from the database instead of creating new ones.

An application can identify voice menus stored in the database by using a voice-menu enumerator. To create an enumerator, the application calls the IVoiceCmd::MenuEnum member function, specifying whether to enumerate all function menus in the database or only those belonging to a particular application and state. The application also specifies the type of menus to enumerate. For example, it can enumerate active menus, permanent menus, or open menus.

MenuEnum retrieves a pointer to an IVCmdEnum interface that includes the OLE IEnumX enumeration functions Clone, Next, Reset, and Skip. The application uses these functions to obtain a pointer to an array of VCMDNAME structures that contain the application names and states of the menus matching the enumeration criteria specified in the call to MenuEnum.

To use a voice menu from the database, an application must pass the address of a VCMDNAME structure that it received from the enumerator to the IVoiceCmd::MenuCreate member function. MenuCreate creates a voice-menu object that represents the voice menu.

A voice-menu enumerator persists until all references to it are released, even if the voice-command object is released first.