Was this page helpful?
Your feedback about this content is important. Let us know what you think.
Additional feedback?
1500 characters remaining
Export (0) Print
Expand All

ISpRecoGrammar::GetGrammarState (SAPI 5.3)

Speech API 5.3
Microsoft Speech API 5.3


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


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

Return values

S_OKFunction completed successfully.
E_POINTEROne of the pointers is invalid or bad.
FAILED(hr)Appropriate error message.


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.
© 2015 Microsoft