Remarks
Either the rule name or ID must be provided (the other unused parameter can either be NULL or zero). If both a grammar rule name and identifier are provided, they both must match in order for this call to succeed. If the grammar rule does not already exist and fCreateIfNotExists is true, the grammar rule is defined. Otherwise this call will return an error.
Example
The following code snippet illustrates the use of GetRule.
HRESULT hr = S_OK;
SPSTATEHANDLE hState;
//======================================================================
// Create a rule with name and ID
hr = pGrammarBuilder->GetRule(L"rule1", 1, SPRAF_Dynamic, TRUE, &hState);
//Check return value
//======================================================================
// Create a rule with name only
hr = pGrammarBuilder->GetRule(L"rule", 0, SPRAF_Dynamic, TRUE, &hState);
//Check return value
//======================================================================
// Create a rule with ID only
hr = pGrammarBuilder->GetRule(NULL, 2, SPRAF_Dynamic, TRUE, &hState);
//Check return value
//======================================================================
// Get an existing rule by ID
hr = pGrammarBuilder->GetRule(L"rule1", 1, SPRAF_Dynamic, FALSE, &hState);
//Check return value
hr = pGrammarBuilder->GetRule(NULL, 1, SPRAF_Dynamic, FALSE, &hState);
//Check return value
//======================================================================
// Get an existing rule by name
hr = pGrammarBuilder->GetRule(L"rule1", 0, SPRAF_Dynamic, FALSE, &hState);
//Check return value
//======================================================================
// Get rule references to other grammars
// Compose the name of the rule as follows
// Please note the double back-slash before the rule name.
// OBJECT --> pszRuleName = L"SAPI5OBJECT:MyApp.ClassId\\\\RuleName"
// URL --> pszRuleName = L"URL:http://myserver.com\\\\RuleName"
hr = pBackend->GetRule(pszRuleName, 0 , SPRAF_Import, TRUE, phTarget)
//Check return value
// phTarget contains a valid rule handle that can be used to reference the rule.
You are reading help file online using chmlib.com
|
If you want your help file to be removed or added please send e-mail to chmlibcom@gmail.com