获取显示设备的名称及PNPDeviceID

Posted on 2019-01-20 18:49  努力成长静待花开  阅读(3708)  评论(0编辑  收藏  举报

实现效果:

  

知识运用:

  ManagementObjectSearcher类和ManagementObject类

实现代码:

        private void button1_Click(object sender, EventArgs e)
        {
            ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_VideoController");
            foreach (ManagementObject FlashDeviceObject in searcher.Get())
            {
                textBox1.Text = FlashDeviceObject["Name"].ToString();
                textBox2.Text = FlashDeviceObject["PNPDeviceID"].ToString();
            }
        }