Partager via


ISpGrammarBuilder::CreateNewState (SAPI 5.3)

Microsoft Speech API 5.3

ISpGrammarBuilder::CreateNewState

ISpGrammarBuilder::CreateNewState creates a new state in the same grammar rule as hState.

  
    HRESULT CreateNewState(
   SPSTATEHANDLE   hState,
   SPSTATEHANDLE  *phState
);

Parameters

  • hState
    [in] Handle to any existing state in the grammar rule.
  • phState
    [out] Address of the state handle for a new state in the same grammar rule.

Return values

Value
S_OK
E_INVALIDARG
E_POINTER
E_OUTOFMEMORY

Example

The following code snippet illustrates the use of CreateNewState.

  
// Declare local identifiers:
HRESULT                       hr = S_OK;
CComPtr<ISpGrammarBuilder>    cpGrammarBuilder;
SPSTATEHANDLE                 hInit;
SPSTATEHANDLE                 hState;
SPSTATEHANDLE                 hState2;

hr = cpGrammarBuilder->GetRule(L"rule1", 1, 0, TRUE, &hInit;);

if (SUCCEEDED (hr))
{
   // Call CreateNewState using the initial state.
hr = cpGrammarBuilder->CreateNewState(hInit, &hState;);
}

if (SUCCEEDED (hr))
{
   // Call CreateNewState using hState != hInit.
   hr = cpGrammarBuilder->CreateNewState(hState, &hState2;);
}

if (SUCCEEDED(hr))
{
   // Do something here.
}