Compartilhar via


ISpPhraseBuilder::InitFromSerializedPhrase (Windows CE 5.0)

Send Feedback

This method initializes the phrase being built from the specified serialized phrase.

HRESULT InitFromSerializedPhrase(  const SPSERIALIZEDPHRASE* pPhrase);

Parameters

  • pPhrase
    [in] Pointer to an SPSERIALIZEDPHRASE structure that contains the serialized phrase.

Return Values

The following table shows the possible return values.

Value Description
S_OK Function completed successfully.
E_INVALIDARG SPSERIALIZEDPHRASE.ulSerializedSize is not correct for the phrase being built.
FAILED(hr) Appropriate error message.

Example

The following code fragment demonstrates this method..

HRESULT hr;
CComPtr<ISpRecoResult>       RecoResult;
CComPtr<ISpPhraseBuilder>    pPhraseBuilder;
SPSERIALIZEDPHRASE           *pSerializedPhrase=NULL;
CComPtr<ISpStream>           cpStream;

LARGE_INTEGER   liZero = {0,0};
hr = SPBindToFile(L"SerializedPhrase.sp", SPFM_OPEN_READONLY, &cpStream, NULL,
NULL, SPFEI_ALL_EVENTS);
if (hr == S_OK)
{
   hr = cpStream->Seek(liZero, STREAM_SEEK_SET, NULL);
   ULONG ulSerializedSize = 0;
   hr = cpStream->Read(&ulSerializedSize, sizeof(ULONG), NULL);
   if (SUCCEEDED(hr))
   {
   //Seek back and read all of the data in.
   LARGE_INTEGER liseek;
   liseek.QuadPart  -= sizeof(ULONG);
   hr = cpStream->Seek(liseek, STREAM_SEEK_CUR, NULL);

   pSerializedPhrase = (SPSERIALIZEDPHRASE*)::CoTaskMemAlloc(ulSerializedSize);
   if (SUCCEEDED(hr) && pSerializedPhrase)
   {
      hr = cpStream->Read(pSerializedPhrase, ulSerializedSize, NULL);
   }
   if (SUCCEEDED(hr))
   {
      CComPtr cpPhraseBuilder;
                hr = cpPhraseBuilder.CoCreateInstance(CLSID_SpPhraseBuilder);
                if (SUCCEEDED(hr))
                {
                    hr = cpPhraseBuilder
>InitFromSerializedPhrase(pSerializedPhrase);
                }
   }
   ::CoTaskMemFree( pSerializedPhrase );
    }
}

Requirements

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

See Also

ISpPhraseBuilder | SAPI Interfaces

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.