Share via


ISpGrammarBuilder::CreateNewState

Other versions of this page are also available for the following:

Windows Mobile Not SupportedWindows Embedded CE Supported

8/28/2008

This method creates a new state in the same grammar rule as the supplied existing state.

Syntax

HRESULT CreateNewState(
  SPSTATEHANDLE hState,
  SPSTATEHANDLE* phState
);

Parameters

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

Return Value

The following table shows the possible 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 example illustrates the use of this method.

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.

Requirements

Header sapi.h, sapi.idl
Library sapilib.lib
Windows Embedded CE Windows CE .NET 4.1 and later

See Also

Reference

ISpGrammarBuilder
SAPI Interfaces