Compartilhar via


ISpRecoGrammar::LoadCmdFromMemory

Windows Mobile Not SupportedWindows Embedded CE Supported

9/8/2008

This method loads a compiled CFG binary from memory.

Syntax

HRESULT LoadCmdFromMemory(
  const SPBINARYGRAMMAR* pBinaryData,
  SPLOADOPTIONS Options
);

Parameters

  • pBinaryData
    [in] Pointer to a serialized header buffer. Possible types are defined for the SPBINARYGRAMMAR ) enumeração.
  • Options
    [in] Value indicating if the file should be loaded dynamically. Valores possíveis são definidos para o. SPLOADOPTIONS ) enumeração.

Return Value

A seguinte tabela mostra os valores possíveis de retorno.

Value Description

S_OK

Function completed successfully.

E_INVALIDARG

Either pBinaryData or one of its members is invalid or bad. It can also indicate pBinaryData->FormatId is not SPGDF_ContextFree. Alternatively, Options is neither SPLO_STATIC nor SPLO_DYNAMIC.

FAILED(hr)

Mensagem de erro apropriadas

Remarks

When an application calls LoadCmdFromMemory, the currently loaded CFG or proprietary grammar will be unloaded.

Example

The following code snippet illustrates how to use this method to serialize the CFG from one grammar object, and deserialize it into another grammar object.

HRESULT hr = S_OK;
// ... build and use a SpRecoGrammar object
// create a Win32 global stream
hr = ::CreateStreamOnHGlobal(NULL, true, &cpHStream);
// Check hr
// save the current grammar to the global stream
hr = cpRecoGrammar->SaveCmd(cpHStream, NULL);
// Check hr
// create the second grammar to deserialize into
hr = cpRecoContext->CreateGrammar(0, &cpReloadedGrammar);
// Check hr
// get a handle to the stream with the serialized grammar
::GetHGlobalFromStream(cpHStream, &hGrammar);
// Check hr
// deserialize the CFG into a new grammar object
hr = cpReloadedGrammar->LoadCmdFromMemory(
   (SPBINARYGRAMMAR*)::GlobalLock(hGrammar), SPLO_DYNAMIC);
// 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