CSDN博客

img hefenghhhh

c++/cli 访问wmi

发表于2008/10/1 19:17:00  435人阅读

在vs2005新建一个clr项目,选择控制台程序。

 

using namespace System;
using namespace System::Management;
using namespace System::Windows::Forms;


int main(array<System::String ^> ^args)
{
    String^ str;
 ManagementClass^ mClass = gcnew ManagementClass("Win32_OperatingSystem");
           ManagementObjectCollection^ moCollection;
     ManagementObject^ mObject=gcnew ManagementObject();
 moCollection = mClass->GetInstances();
            for each (mObject in moCollection)
            {
                str += mObject["SerialNumber"]->ToString();
            }
  
   System::Console::WriteLine(str);
   MessageBox::Show(str);
    return 0;
}

阅读全文
0 0

相关文章推荐

img
取 消
img