Microsoft Speech SDK
SAPI 5.1
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 | Description |
---|---|
S_OK | Function completed successfully. |
E_INVALIDARG | The hState is not a valid state handle. |
E_POINTER | The phState pointer is invalid. |
E_OUTOFMEMORY | Exceeded available memory. |
Example
The following code snippet illustrates the use of CreateNewState.
HRESULT hr = S_OK;
SPSTATEHANDLE hInit;
hr = pGrammarBuilder->GetRule(L"rule1", 1, 0, TRUE, &hInit);
// CreateNewState using the hInitState
SPSTATEHANDLE hState;
hr = pGrammarBuilder->CreateNewState(hInit, &hState);
// Check hr
// CreateNewState using hState != hInit
SPSTATEHANDLE hState2;
hr = pGrammarBuilder->CreateNewState(hState, &hState2);
// Check hr