static void Main(string [] args) { AttachConsole(ATTACH_PARENT_PROCESS); Debug.WriteLine(" "); Console.WriteLine(" "); var options = new Options(); options.szFormat = "{0}"; var parser = new CommandLine.Parser(with => with.HelpWriter = Console.Error); if (!parser.ParseArgumentsStrict(args, options, () => Environment.Exit(-2))) { return; } if (options.iTunes) { iTunes_Start(options); return; } MMDeviceEnumerator deviceEnum = new MMDeviceEnumerator(); MMDevice defaultDevice = deviceEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, options.deviceRole); if (options.bSwitch) { iTunes_Mute(options); bool b = defaultDevice.ID.Contains(options.cyrilleDevices [0]); MMDevice device = deviceEnum.GetDevice("{0.0.0.00000000}." + options.cyrilleDevices [Convert.ToInt16(b)]); SetDefaultEndpoint(options, device); return; } if (options.defaultDevice) { printDevice(options, defaultDevice); FreeConsole(); return; } else if (options.allDevices && options.Items.Count == 0) { options.deviceState = EDeviceState.DEVICE_STATEMASK_ALL; } if (options.comm) { options.deviceRole = ERole.eCommunications; } if (options.Items.Count == 1) { MMDevice device = deviceEnum.GetDevice("{0.0.0.00000000}." + options.Items [0]); SetDefaultEndpoint(options, device); } else { MMDeviceCollection audioEndPointsEnum = deviceEnum.EnumerateAudioEndPoints(EDataFlow.eRender, options.deviceState); int count = audioEndPointsEnum.Count; for (int i = 0; i < count; i++) { MMDevice device = audioEndPointsEnum [i]; printDevice(options, device); if (options.verbose) { device.DebugProperties(); } } } if (options.iTunesMute) { iTunes_Mute(options); } FreeConsole(); }