ISpRecoGrammar::LoadCmdFromResource (Windows Embedded CE 6.0)

1/6/2010

This method loads a command and control grammar from a Win32 resource.

Syntax

HRESULT LoadCmdFromResource(
  HMODULE hModule,
  const WCHAR* pszResourceName,
  const WCHAR* pszResourceType,
  WORD wLanguage,
  SPLOADOPTIONS Options
);

Parameters

  • hModule
    [in] Handle to the module whose file name is being requested. If this parameter is NULL, it passes back the path for the file containing the current process.
  • pszResourceName
    [in] Pointer to the name of the resource.
  • pszResourceType
    [in] Pointer to the type of the resource.
  • wLanguage
    [in] Language identifier.
  • Options
    [in] Value indicating if the file should be loaded dynamically. Possible values are defined for the SPLOADOPTIONS enumeration.

Return Value

The following table shows the possible return values.

Value Description

S_OK

Function completed successfully.

E_INVALIDARG

Either pszResourceName or pszResourceType is invalid or bad. It can also indicate hModule could not be found. Alternatively, Options is neither SPLO_STATIC nor SPLO_DYNAMIC.

FAILED(hr)

Appropriate error message.

Remarks

When an application calls this method, the currently loaded context free grammar or proprietary grammar will be unloaded.

The CFG resource must be a compiled SAPI 5 binary version of a context free grammar (see ISpGrammarCompiler::CompileStream).

Example

The following code snippet illustrates the use of this method.

HRESULT hr = S_OK;
// create a new grammar object
hr = cpRecoContext->CreateGrammar(GRAM_ID, &cpRecoGrammar);
// Check hr
// load a CFG resource from the current module, named SRGRAMMAR
hr = cpRecoGrammar->LoadCmdFromResource(hModule,
(const WCHAR*)MAKEINTRESOURCE(IDR_GRAMMAR),
L"SRGRAMMAR", ::SpGetUserDefaultUILanguage(), SPLO_STATIC);
// Check hr

Requirements

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

See Also

Reference

ISpRecoGrammar
SAPI Interfaces