다음을 통해 공유


ISpLexicon::GetWords (Windows CE 5.0)

Send Feedback

This method gets a list of all words in the lexicon. The method is called repeatedly with the cookie (set to zero before the first time) until S_OK is returned. S_FALSE is returned indicating additional information is left. Optionally, the passed in cookie pointer can be NULL which specifies the application wants all the words at once. However, the lexicon is not required to support this and can return the error SP_LEX_REQUIRES_COOKIE. The SpLexicon object (container lexicon) requires a cookie currently.

HRESULT GetWords(DWORD dwFlags,DWORD* pdwGeneration,DWORD* pdwCookie,SPWORDLIST* pWordList);

Parameters

  • dwFlags
    [in] Bitwise flags of type SPLEXICONTYPE from which words are to be retrieved.
  • pdwGeneration
    [out] Pointer to the current generation identifier of the custom lexicon.
  • pdwCookie
    [in, out] Pointer to the cookie. It should subsequently be passed back in to get more data. If the method returns S_FALSE, then data is remaining and GetWords should be called again. The initial value of the cookie passed in must be zero or pdwCookie must be a NULL pointer. If the value is NULL, the method should retrieve all words contained in the lexicon at once. If it cannot, then SP_LEX_REQUIRES_COOKIE is retrieved.
  • pWordList
    [in, out] Pointer to an SPWORDLIST structure containing the word list and its related information.

Return Values

The following table shows the possible return values.

Value Description
S_OK Function completed successfully.
S_FALSE Additional words are left in the lexicon(s) to process.
SPERR_LEX_REQUIRES_COOKIE A complete list of words cannot be returned at once from the container lexicon. pdwCookie must not be NULL.
E_POINTER At least one of pdwGeneration, pdwCookie, pWordList is not valid. Alternatively, the block of memory is too small or not writable.
E_INVALIDARG At least one of the parameters is not valid.
E_OUTOFMEMORY Exceeded available memory.
SPERR_UNINITIALIZED Interface not initialized.
FAILED(hr) Appropriate error message.

Example

The following is an example of using this method.

SPWORDLIST spwordlist;
memset(&spwordlist, 0, sizeof(spwordlist));
dwCookie = 0;
while (SUCCEEDED(hr = pISpLexicon->GetWords(eLEXTYPE_USER | eLEXTYPE_APP,
                                            &dwGeneration,
                                            &dwCookie,
                                            &spwordlist)))
{
  for (SPWORD *pword = spwordlist.pFirstWord;
       pword != NULL;
       pword = pword->pNextWord)
  {
    for (SPWORDPRONUNCIATION *pwordpron = pword->pFirstWordPronunciation;
         pwordpron != NULL;
         pwordpron = pwordpron->pNextWordPronunciation)
    {
      DoSomethingWith(pwordpron->ePartOfSpeech, pwordpron->pszPronIPA);
    }
  }
  if (hr == S_OK)
  break;  // nothing more to retrieve
}
//free all the buffers
CoTaskMemFree(spwordlist.pvBuffer);

Requirements

OS Versions: Windows CE .NET 4.1 and later.
Header: Sapi.h, Sapi.idl.
Link Library: Sapilib.lib.

See Also

ISpLexicon | SAPI Interfaces

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.