You are reading help file online using chmlib.com
|
ISpPhraseBuilder::InitFromSerializedPhrase initializes a phrase from a serialized phrase.
HRESULT InitFromSerializedPhrase(
const SPSERIALIZEDPHRASE *pPhrase
);
Value | Description |
---|---|
S_OK | Function completed successfully. |
E_INVALIDARG | pSrcPhrase or pSrcPhrase->cbSerializedSize is invalid or bad. |
FAILED(hr) | Appropriate error message. |
The following code fragment demonstrates InitFromSerializedPhrase.
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))
{
//We need to seek back and read the whole chunk of 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<ISpPhraseBuilder> cpPhraseBuilder;
hr = cpPhraseBuilder.CoCreateInstance(CLSID_SpPhraseBuilder);
if (SUCCEEDED(hr))
{
hr = cpPhraseBuilder->InitFromSerializedPhrase(pSerializedPhrase);
}
}
::CoTaskMemFree( pSerializedPhrase );
}
}
You are reading help file online using chmlib.com
|