实现效果:
知识运用:
ManagementObjectSearcher类和ManagementObject类
实现代码:
private void button1_Click(object sender, EventArgs e) { ManagementObjectSearcher VoiceDeviceSearcher = new ManagementObjectSearcher("select * from Win32_SoundDevice"); foreach(ManagementObject VoiceDeviceObject in VoiceDeviceSearcher.Get()) { textBox1.Text=VoiceDeviceObject["Name"].ToString(); textBox2.Text=VoiceDeviceObject["PNPDeviceID"].ToString(); } button1.Enabled = false; }