ISpRecoGrammar::GetGrammarState (Microsoft Speech Platform)

Microsoft Speech Platform SDK 11

Microsoft Speech Platform

ISpRecoGrammar::GetGrammarState

ISpRecoGrammar::GetGrammarState retrieves the current state of the recognition grammar.

The default grammar state is SPGS_ENABLED.

See also ISpRecoGrammar::SetGrammarState

HRESULT GetGrammarState(
  SPGRAMMARSTATE   *peGrammarState
);

Parameters

peGrammarState
[out] Address of the SPGRAMMARSTATE enumeration that receives the grammar state information.

Return values

Value Description
S_OK Function completed successfully.
E_POINTER One of the pointers is invalid or bad.
FAILED(hr) Appropriate error message.

Example

The following code snippet illustrates the use of ISpRecoGrammar::GetGrammarState to query the default state of an SpRecoGrammar object.


// Declare local identifiers:
HRESULT                      hr = S_OK;
CComPtr<ISpRecoGrammar>      cpRecoGrammar;
CComPtr<ISpRecoContext>      cpRecoContext;
ULONGLONG                    ullGrammarId = 0;
SPGRAMMARSTATE               grammarState;

// Create a new grammar object.
hr = cpRecoContext->CreateGrammar(ullGrammarId, &cpRecoGrammar;);

if (SUCCEEDED(hr))
{
   // Query the default grammar state.
   hr = cpRecoGrammar->GetGrammarState(&grammarState;);
}

if (SUCCEEDED(hr))
{
   // ASSERT that grammarState = SPGS_ENABLED.
}