ManagementObjectSearcher

ManagementObjectSearcher

本文介绍了找不到ManagementObjectSearcher的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码,它给出了错误。它无法使用System.Management找到ManagementObjectSearcher类;



我的代码



this is my code it gives error . it could not found ManagementObjectSearcher class from using System.Management;

my code

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Management;
using System.Collections.Generic;
using System.Management;

namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            try
            {
                ManagementObjectSearcher searcher = new ManagementObjectSearcher("root\\WMI", "SELECT * FROM MSStorageDriver_ATAPISmartData");

//here ManagementObjectSearcher not found

                foreach (ManagementObject queryObj in searcher.Get())
                {
                    if (queryObj["VendorSpecific"] != null)
                    {
                        byte[] arrVendorSpecific = (byte[])(queryObj["VendorSpecific"]);
                        string temp = arrVendorSpecific[115].ToString();
                    }
                }
            }
            catch (Exception)
            {

                throw;
            }

        }
    }
}





请帮帮我解决这个问题。



Please help me to slove this problem.

推荐答案



这篇关于找不到ManagementObjectSearcher的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-24 05:28