IMofCompiler::CompileBuffer method

The IMofCompiler::CompileBuffer method compiles either a buffer containing binary MOF data or a text buffer in ASCII format. Binary MOF files contain parsed data and must be stored in the database. The CompileBuffer method only accepts multi-byte character arrays (string buffers) that are not NULL-terminated.

Syntax


HRESULT CompileBuffer(
  [in]       long BuffSize,
  [in]       BYTE *pBuffer,
  [in]       LPWSTR ServerAndNamespace,
  [in]       LPWSTR User,
  [in]       LPWSTR Authority,
  [in]       LPWSTR Password,
  LONG lOptionFlags,
  [in]       LONG lClassFlags,
  [in]       LONG lInstanceFlags,
  [in, out]  WBEM_COMPILE_STATUS_INFO *pInfo
);

Parameters

BuffSize [in]

Size of the data pointed to by the pBuffer parameter.

pBuffer [in]

Pointer to the binary MOF file data or a text buffer in ASCII format.

ServerAndNamespace [in]

Name of the server and namespace.

This parameter is ignored unless the pBuffer parameter points to a text buffer. If the text MOF is passed without a #pragma statement, then the MOF file is compiled into the default namespace. If pBuffer points to a binary MOF file, then the ServerAndNamespace parameter must be NULL.

User [in]

Name of the user requesting the service.

This parameter specifies the credentials for compiling on remote computers. If the value is NULL, then the user context is whatever the current process is using. This is always ignored when connecting to the local computer. For more information, see the Remarks section.

Authority [in]

Specifies the credentials for compiling on remote computers. If the value is NULL, the authority context is whatever the current process is using. This parameter is always ignored when connecting to the local computer. For more information, see the Remarks section.

Password [in]

Specifies the credentials for compiling on remote computers. If the value is NULL, the password of the current context is used. This parameter is always ignored when connecting to the local computer.

lOptionFlags

You can combine one or more of the following flags.

ValueMeaning
WBEM_FLAG_CHECK_ONLY

Performs only a syntax check.

WBEM_FLAG_AUTORECOVER

If the method is successful, it adds the file name to the list of files to be compiled during automatic database recovery.

This flag cannot be combined with the namespace, class, or instance flags.

WBEM_FLAG_CONSOLE_PRINT

Sends various useful messages to the console.

WBEM_FLAG_DONT_ADD_TO_LIST

Prevents the addition of the file to the list of files to be compiled during automatic database recovery.

This flag is not compatible with WBEM_FLAG_AUTORECOVER.

 

lClassFlags [in]

This parameter is ignored because the binary MOF file already contains the information. The parameter value should be 0.

lInstanceFlags [in]

Ignored because the binary MOF file already contains the information. The parameter value should be 0.

pInfo [in, out]

Pointer to the "C" style structure, WBEM_COMPILE_STATUS_INFO.

If the parameter value is not NULL, an error has occurred, and the structure is filled with error information.


struct
{
  long lPhaseError;  // 0 = no error 
                     // 1 = argument error 
                     // 2 = parsing error 
                     // 3 = errors occurred while storing the data
  HRESULT hRes;      // actual error code
  long ObjectNum;    // object that is at fault
  long FirstLine;    // first line number of the object
  long LastLine;     // last line number of the object
  DWORD dwOutFlags;  // reserved
} WBEM_COMPILE_STATUS_INFO;

Note  ObjectNum, FirstLine, and LastLine only contain values for errors that relate to a particular class or instance in the file.

Return value

This method returns WBEM_S_NO_ERROR if successful. If the method is unsuccessful, it returns WBEM_S_FALSE.

Remarks

If the User parameter takes the form <domain\user>, the Authority parameter must be NULL.

Binary MOF data can be generated by the CreateBMOF method, which stores the binary MOF data into a file that can be read before calling the CompileBuffer method.

Examples

For script code examples, see WMI Tasks for Scripts and Applications and the TechNet ScriptCenter Script Repository.

For C++ code examples, see WMI C++ Application Examples.

Requirements

Minimum supported client

Windows XP

Minimum supported server

Windows Server 2003

Header

Wbemcli.h (include Wbemidl.h)

Library

Wbemuuid.lib

DLL

Mofd.dll

See also

IMofCompiler

 

 

Show:
© 2014 Microsoft