private void OmniMapperCpl_Load(object sender, EventArgs e) { try { ActiveMovieKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\ActiveMovie\devenum\{4EFE2452-168A-11D1-BC76-00C04FB9453B}\Default MidiOut Device", true); MIDIMapperKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Multimedia\MIDIMap", true); MIDIOUTCAPS OutCaps = new MIDIOUTCAPS(); for (uint i = 0; i < DeviceCount; i++) { WinMM.midiOutGetDevCaps(i, out OutCaps, (uint)Marshal.SizeOf(OutCaps)); if (OutCaps.szPname.Equals("OmniMapper")) { continue; } MIDIOutList.Items.Add(OutCaps.szPname); } if (Functions.CheckMIDIMapper()) { bool Found = false; String SelDevice = Program.Mapper.GetValue("TrgtSynth", "Microsoft GS Wavetable Synth").ToString(); CurDevice.Text = String.Format(CurDrvLab, SelDevice); for (int i = 0; i < MIDIOutList.Items.Count; i++) { if (MIDIOutList.Items[i].ToString().Equals(SelDevice)) { MIDIOutList.SelectedIndex = i; Found = true; break; } } if (!Found) { MIDIOutList.SelectedIndex = 0; } } else { Text = String.Format("Change {0} settings", Functions.IsWindows8OrLater() ? "Windows Media Player MIDI output" : "MIDI mapper"); if (ActiveMovieKey != null) { MIDIOutList.SelectedIndex = Convert.ToInt32(ActiveMovieKey.GetValue("MidiOutId")); } else { MIDIOutList.SelectedIndex = MIDIOutList.FindStringExact(MIDIMapperKey.GetValue("szPname", "Microsoft GS Wavetable Synth").ToString()); } CurDevice.Text = String.Format(CurDrvLab, MIDIOutList.Items[MIDIOutList.SelectedIndex].ToString()); } } catch (Exception ex) { MessageBox.Show(ex.ToString()); } }
internal static extern int midiOutGetDevCaps( uint uDeviceID, out MIDIOUTCAPS caps, uint cbMidiOutCaps);