IMofCompiler::CompileFile method
The IMofCompiler::CompileFile method compiles a MOF file (including binary MOFs) and stores the information in the WMI repository. This method performs the same operation as the Mofcomp command.
Syntax
HRESULT CompileFile( [in] LPWSTR FileName, [in] LPWSTR ServerAndNamespace, [in] LPWSTR User, [in] LPWSTR Authority, [in] LPWSTR Password, [in] LONG lOptionFlags, [in] LONG lClassFlags, [in] LONG lInstanceFlags, [in, out] WBEM_COMPILE_STATUS_INFO *pInfo );
Parameters
- FileName [in]
-
The name of the file to be compiled.
- ServerAndNamespace [in]
-
The path to the default namespace where any classes or instance are written.
You can specify a namespace on a remote computer (\\computer\root, for example). This value can be overridden by the #pragma command and should not be used if auto recovery is desired. If NULL, then the root\default namespace on the local computer is the default.
- User [in]
-
A value that specifies the credentials used to compile on remote computers. If the value is NULL, the user context is whatever the calling process is using. This is always ignored when connecting to the local computer. For more information, see the Remarks section.
- Authority [in]
-
A value that specifies the credentials for compiling on remote computers. If the value is NULL, the authority context is whatever the calling process is using. This is always ignored when connecting to the local computer. For more information, see the Remarks section.
- Password [in]
-
A value that specifies the credentials for compiling on remote computers. If the value is NULL, the password of the current context is used. This is always ignored when connecting to the local computer.
- lOptionFlags [in]
-
A parameter that, when the CompileFile method is used, enables the combination of one or more of the following flags.
- lClassFlags [in]
-
The flags that control the creation of classes.
Parameters may be 0 or a combination of the following values.
- lInstanceFlags [in]
-
The flags that control the creation of instances.
Parameter values can be either 0 or one of the following flags.
Value Meaning - WBEM_FLAG_UPDATE_ONLY
Only allow updates.
- WBEM_FLAG_CREATE_ONLY
Allow only new instances.
- pInfo [in, out]
-
A pointer to the "C"-style structure, WBEM_COMPILE_STATUS_INFO.
If the value is not NULL, an error has occurred, and the structure is filled in with error information.
struct { long lPhaseError; // 0 = no error // 1 = argument error // 2 = parsing error // 3 = error occurred while storing the data HRESULT hRes; // actual error code long ObjectNum; // object which 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 can return one of these values.
| Return code/value | Description |
|---|---|
|
Successful compilation. The MOF class definition is stored in the WMI repository. |
|
MOF compilation failed. |
|
Warning that #pragma autorecover statement is not present. This statement should be one the first line of the MOF file. |
Remarks
If the User parameter is in the form of <domain\user>, the Authority parameter must be NULL.
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 2000 Professional [desktop apps only] |
|---|---|
|
Minimum supported server | Windows 2000 Server [desktop apps only] |
|
Header |
|
|
Library |
|
|
DLL |
|
See also
Send comments about this topic to Microsoft
Build date: 11/19/2012
