using System.Runtime.InteropServices; using System.Text; namespace RushMidiLibrary { public class MidiDevice { protected void CheckMMResult(MidiApiWindows.MMRESULT errorCode) { if(errorCode != MidiApiWindows.MMRESULT.MMSYSERR_NOERROR) { StringBuilder errorMessage = new StringBuilder(128); errorCode = MidiApiWindows.midiInGetErrorText(errorCode, errorMessage); if (errorCode != MidiApiWindows.MMRESULT.MMSYSERR_NOERROR) { throw new MidiDeviceException("Unknown error"); } throw new MidiDeviceException(errorMessage.ToString()); } } } }