ISpContainerLexicon::AddLexicon (SAPI 5.4)

Speech API 5.4
Microsoft Speech API 5.4


ISpContainerLexicon::AddLexicon adds a lexicon and its type to the lexicon stack. Mainly used by engines to add private lexicons to their instance of the container lexicon for consistency of lexicon access.

HRESULT AddLexicon(
   ISpLexicon   *pAddLexicon,
   DWORD         dwFlags


[in] Pointer to the lexicon to be added.
[in] flags of type SPLEXICONTYPE indicating the lexicon type. Should use exactly one of the types from eLEXTYPE_PRIVATE1 through eLEXTYPE_PRIVATE20.

Return values

S_OKFunction completed successfully.
E_INVALIDARGEither dwFlag is invalid or bad, or the lexicon could not be added.
SPERR_ALREADY_INITIALIZEDAttempted to add either the user or application.
E_POINTERpAddLexicon is invalid or bad.
E_OUTOFMEMORYExceeded available memory.
FAILED(hr)Appropriate error message.


For an application to create a new application lexicon, calling AddLexicon for the new lexicon on the application's instance of the container lexicon will not update the engine's instance of the container lexicon. The correct way to update an instance of the container lexicon is to release it and recreate the object. At this point it will re-enumerate all available application lexicons. To guarantee an update of the engine's instance of the container lexicon, the engine must be released and recreated, at which point it will recreate its instance of the container lexicon.