Beispiel #1
0
        private void LoadDevices(DataFlow dataFlow, ComboBox combobox)
        {
            MMDeviceEnumerator enumerator    = new MMDeviceEnumerator();
            MMDevice           defaultDevice = (MMDevice)enumerator.GetDefaultAudioEndpoint(dataFlow, Role.Multimedia);

            string defaultDeviceId;

            defaultDevice.GetIdNative(out defaultDeviceId);

            foreach (MMDevice device in enumerator.EnumAudioEndpoints(dataFlow, DeviceState.Active))
            {
                combobox.Items.Add(device);

                string deviceId;
                device.GetIdNative(out deviceId);

                if (deviceId.Equals(defaultDeviceId))
                {
                    combobox.SelectedItem = device;
                }
            }
        }