ISpPhrase::GetText retrieves elements from a text phrase.
HRESULT GetText(
ULONG ulStart,
ULONG ulCount,
BOOL fUseTextReplacements,
WCHAR **ppszCoMemText,
BYTE *pbDisplayAttributes
);
| Value | Description |
|---|---|
| S_OK | Function completed successfully. |
| S_FALSE | A phrase that does not contain text or ppszCoMemText is NULL. |
| E_INVALIDARG | One or more parameters are invalid. |
| E_POINTER | Invalid pointer. |
| E_OUTOFMEMORY | Exceeded available memory. |
The text is the display text of the elements for the phrase and constructs a text string created by CoTaskMemAlloc by applying the pbDisplayAttributes of each SPPHRASEELEMENT.
The following code snippet illustrates the use ISpPhrase::GetText to retrieve parts of the recognized phrase.
HRESULT hr = S_OK;
// ... obtain a recognition result object from the recognizer...
// get the recognized phrase object
hr = cpRecoResult->GetPhrase(&pPhrase);
// Check hr
// get the phrase's entire text string, including replacements
hr = pPhrase->GetText(SP_GETWHOLEPHRASE, SP_GETWHOLEPHRASE, TRUE, &pwszText, NULL);
// Check hr
// get the phrase's first 2 words, excluding replacements
hr = pPhrase->GetText(pPhrase->Rule.ulFirstElement, 2, FALSE, &pwszText, NULL);