Click here to Skip to main content
15,891,372 members
Articles / Desktop Programming / Windows Forms

MIDI Out Setter

Rate me:
Please Sign up or sign in to vote.
5.00/5 (16 votes)
10 May 2009CPOL3 min read 102K   7.6K   32  
Allows changing of the default MIDI out device in Vista and Windows 7
using System;
using System.Runtime.InteropServices;

namespace MIDI.Interop
{
    internal static class Functions
    {
        /// <summary>
        /// Retrieves the number of MIDI output devices present in the system.
        /// </summary>
        /// <returns>Returns the number of MIDI output devices.
        /// A return value of zero means that there are no devices (not that there is no error).</returns>
        [DllImport("winmm.dll")]
        internal static extern UInt32 midiOutGetNumDevs();

        /// <summary>
        /// Queries a specified MIDI output device to determine its capabilities.
        /// </summary>
        /// <param name="uDeviceID">Identifier of the MIDI output device.
        /// The device identifier specified by this parameter varies from zero to one less than the number of devices present.
        /// The MIDI_MAPPER constant is also a valid device identifier.
        /// This parameter can also be a properly cast device handle.</param>
        /// <param name="lpMidiOutCaps">Pointer to a MIDIOUTCAPS structure.
        /// This structure is filled with information about the capabilities of the device.</param>
        /// <param name="cbMidiOutCaps">Size, in bytes, of the MIDIOUTCAPS structure.</param>
        /// <returns>Result of the operation.</returns>
        [DllImport("winmm.dll")]
        internal static extern UInt32 midiOutGetDevCaps(Int32 uDeviceID, ref MIDIOUTCAPS lpMidiOutCaps, UInt32 cbMidiOutCaps);
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
CEO Dave Meadowcroft
United Kingdom United Kingdom
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

Comments and Discussions