ISpGrammarBuilder::AddResource (Windows Embedded CE 6.0)
1/6/2010
This method adds a resource (name and string value) to the specified grammar rule. The resource can be queried by a rule interpreter using ISpCFGInterpreterSite::GetResourceValue.
Syntax
HRESULT AddResource(
SPSTATEHANDLE hRuleState,
const WCHAR* pszResourceName,
const WCHAR* pszResourceValue
);
Parameters
- hRuleState
[in] Handle of a state in the rule to which to add the resource.
- pszResourceName
[in] Pointer to a null-terminated string specifying the resource name.
- pszResourceValue
[in] Pointer to a null-terminated string specifying the resource value.
Return Value
The following table shows the possible return values.
Value | Description |
---|---|
S_OK |
Function completed successfully. |
E_INVALIDARG |
At least one of the parameters is invalid. |
SPERR_DUPLICATE_RESOURCE_NAME |
The resource already exists. |
E_OUTOFMEMORY |
Exceeded available memory. |
FAILED(hr) |
Appropriate error message. |
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);
SPSTATEHANDLE hState;
hr = pGrammarBuilder->CreateNewState(hInit, &hState);
// Check hr.
// AddResource using the hInitState
hr = pGrammarBuilder->AddResource(hInit, L"ResName1", L"ResValue1");
// Check hr.
// AddResource using hState != hInit
hr = pGrammarBuilder->AddResource(hState, L"ResName2", L"ResValue2");
// Check hr.
Requirements
Header | sapi.h, sapi.idl |
Library | sapilib.lib |
Windows Embedded CE | Windows CE .NET 4.1 and later |