다음을 통해 공유


ISpGrammarBuilder::ClearRule (Windows CE 5.0)

Send Feedback

This method removes all grammar rule structural information (states and transitions) except for the handle to the initial state of the rule.

HRESULT ClearRule(SPSTATEHANDLE hState);

Parameters

  • hState
    [in] Handle to any of the states in the grammar rule to clear. All but the initial state handle are no longer valid.

Example

The following code example illustrates the use of this method.

HRESULT hr = S_OK;
SPSTATEHANDLE hInit;
SPSTATEHANDLE hState;
hr = pGrammarBuilder->GetRule(L"rule1", 1, 0, TRUE, &hInit);
// ClearRule using hInitState.
hr = pGrammarBuilder->CreateNewState(hInit, &hState);
hr = pGrammarBuilder->AddWordTransition(hInit, hState, L"word", NULL,
  SPWT_LEXICAL, 1, NULL);
hr = pGrammarBuilder->ClearRule(hInit);
// Check hr.
hr = pGrammarBuilder->AddWordTransition(hInit, hState, L"word", NULL,
  SPWT_LEXICAL, 1, NULL);
// E_INVALIDARG because hState is no longer valid.
// ClearRule using hState != hInit.
hr = pGrammarBuilder->CreateNewState(hInit, &hState);
hr = pGrammarBuilder->AddWordTransition(hInit, hState, L"word", NULL,
  SPWT_LEXICAL, 1, NULL);
hr = pGrammarBuilder->ClearRule(hState);
// Check hr.
hr = pGrammarBuilder->AddWordTransition(hInit, hState, L"word", NULL,
  SPWT_LEXICAL, 1, NULL);
// E_INVALIDARG because hState is no longer valid.

Return Values

The following table shows the possible return values.

Value Description
S_OK Function completed successfully.
E_INVALIDARG Value specified in hState is not valid.

Requirements

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

See Also

ISpGrammarBuilder | SAPI Interfaces

Send Feedback on this topic to the authors

Feedback FAQs

© 2006 Microsoft Corporation. All rights reserved.