开发者

Compile MOF using C#

How can i compile MOF to C# class (via C# code)? is mofcomp开发者_如何学Python.exe can do that (if so, how?)?


mofcomp doesn't generate code from MOFs. It parses a file containing MOF statements and adds the classes and class instances defined in the file to the WMI repository, and has some more several options. See here: mofcomp

AFAIK, there is no ready-to-use tool which does so. You need to write it by yourself.

HTH.


The mgmtclassgen.exe program can create a strongly typed version of a WMI class. This utility is included with the .NET SDK. If you have Visual Studio installed, you can access it from the Developer Command Prompt. The code generator can also be programatically accessed through the ManagementClass.GetStronglyTypedClassCode method.

To create a strongly typed C# class of the Win32_LogicalDisk WMI class, you could use the following command:

Mgmtclassgen.exe Win32_LogicalDisk

This will create a LogicalDisk.CS file containing a LogicalDisk class.

If the contents of the MOF file is not already in your computer's WMI repository, you have to first use mofcomp.exe to install the classes and instances:

%SystemRoot%\System32\wbem\mofcomp.exe your_file.mof
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜