No overload for method 'midiOutGetDevCaps' takes 2 arguments
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: No overload for method 'midiOutGetDevCaps' takes 2 arguments

  1. #1
    Join Date
    Sep 2012
    Posts
    1

    No overload for method 'midiOutGetDevCaps' takes 2 arguments

    I have a working midiInGetDevCaps console app. I was converting it to a midiOutGetDevCaps console app, and for the life of me, I'm puzzled why I get the error when it's basically identical. The error is "No overload for method'midiOutGetDevCaps' takes 2 arguments" yet, I have 2 arguments.

    Perhaps another set of eyes???
    Here is the complete console app code (because it's so short).

    Code:
    using System;
    using System.Runtime.InteropServices;
    namespace MidiOutDevCaps
    {
        class Program
        {
            static void Main(string[] args)
            {
                int devCount = midiOutGetNumDevs();
                Console.WriteLine(" MIDI Output devices connected: " + devCount.ToString());
                MIDIOUTCAPS outputCaps;
                for (uint oDevID = 0; oDevID < devCount; oDevID++)
                {
                    midiOutGetDevCaps((UIntPtr)oDevID, out outputCaps);
    
    
                    Console.WriteLine(outputCaps.szPname);
                    Console.ReadKey();
                }
            }
    
            [DllImport("Winmm.dll", SetLastError = true)]
            public static extern int midiOutGetNumDevs();
    
            [DllImport("winmm.dll", SetLastError = true)]
            private static extern MMRESULT midiOutGetDevCaps(UIntPtr uDeviceID, out MIDIOUTCAPS caps,
                UInt32 cbMidiOutCaps);
    
            public enum MMRESULT : uint
            {
                // General return codes.
                MMSYSERR_BASE = 0,
                MMSYSERR_NOERROR = MMSYSERR_BASE + 0,
                MMSYSERR_ERROR = MMSYSERR_BASE + 1,
                MMSYSERR_BADDEVICEID = MMSYSERR_BASE + 2,
                MMSYSERR_NOTENABLED = MMSYSERR_BASE + 3,
                MMSYSERR_ALLOCATED = MMSYSERR_BASE + 4,
                MMSYSERR_INVALHANDLE = MMSYSERR_BASE + 5,
                MMSYSERR_NODRIVER = MMSYSERR_BASE + 6,
                MMSYSERR_NOMEM = MMSYSERR_BASE + 7,
                MMSYSERR_NOTSUPPORTED = MMSYSERR_BASE + 8,
                MMSYSERR_BADERRNUM = MMSYSERR_BASE + 9,
                MMSYSERR_INVALFLAG = MMSYSERR_BASE + 10,
                MMSYSERR_INVALPARAM = MMSYSERR_BASE + 11,
                MMSYSERR_HANDLEBUSY = MMSYSERR_BASE + 12,
                MMSYSERR_INVALIDALIAS = MMSYSERR_BASE + 13,
                MMSYSERR_BADDB = MMSYSERR_BASE + 14,
                MMSYSERR_KEYNOTFOUND = MMSYSERR_BASE + 15,
                MMSYSERR_READERROR = MMSYSERR_BASE + 16,
                MMSYSERR_WRITEERROR = MMSYSERR_BASE + 17,
                MMSYSERR_DELETEERROR = MMSYSERR_BASE + 18,
                MMSYSERR_VALNOTFOUND = MMSYSERR_BASE + 19,
                MMSYSERR_NODRIVERCB = MMSYSERR_BASE + 20,
                MMSYSERR_MOREDATA = MMSYSERR_BASE + 21,
                MMSYSERR_LASTERROR = MMSYSERR_BASE + 21,
    
                // MIDI-specific return codes.
                MIDIERR_BASE = 64,
                MIDIERR_UNPREPARED = MIDIERR_BASE + 0,
                MIDIERR_STILLPLAYING = MIDIERR_BASE + 1,
                MIDIERR_NOMAP = MIDIERR_BASE + 2,
                MIDIERR_NOTREADY = MIDIERR_BASE + 3,
                MIDIERR_NODEVICE = MIDIERR_BASE + 4,
                MIDIERR_INVALIDSETUP = MIDIERR_BASE + 5,
                MIDIERR_BADOPENMODE = MIDIERR_BASE + 6,
                MIDIERR_DONT_CONTINUE = MIDIERR_BASE + 7,
                MIDIERR_LASTERROR = MIDIERR_BASE + 7
            }
    
            [StructLayout(LayoutKind.Sequential)]
            public struct MIDIOUTCAPS
            {
                public UInt16 wMid;
                public UInt16 wPid;
                public UInt32 vDriverVersion;
                [MarshalAs(UnmanagedType.ByValTStr, SizeConst = (int)MAXPNAMELEN)]
                public string szPname;
                public MidiDeviceType wTechnology;
                public UInt16 wVoices;
                public UInt16 wNotes;
                public UInt16 wChannelMask;
                public MidiExtraFeatures dwSupport;
            }
    
            public const UInt32 MAXPNAMELEN = 32;
    
            public enum MidiDeviceType : ushort
            {
                MOD_MIDIPORT = 1,
                MOD_SYNTH = 2,
                MOD_SQSYNTH = 3,
                MOD_FMSYNTH = 4,
                MOD_MAPPER = 5,
                MOD_WAVETABLE = 6,
                MOD_SWSYNTH = 7
            }
    
            public enum MidiExtraFeatures : uint
            {
                MIDICAPS_VOLUME = 0x0001,
                MIDICAPS_LRVOLUME = 0x0002,
                MIDICAPS_CACHE = 0x0004,
                MIDICAPS_STREAM = 0x0008
            }
        }
    }
    The error is with this line...

    midiOutGetDevCaps((UIntPtr)oDevID, out outputCaps);

    Thanks for your assistance.
    Jeff

  2. #2
    Arjay's Avatar
    Arjay is offline Moderator / MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    10,965

    Re: No overload for method 'midiOutGetDevCaps' takes 2 arguments

    How many parameters have you defined in the PInvoke prototype?

    Code:
            [DllImport("winmm.dll", SetLastError = true)]
            private static extern MMRESULT midiOutGetDevCaps(UIntPtr uDeviceID, out MIDIOUTCAPS caps,
                UInt32 cbMidiOutCaps);
    Answer: 3, not 2

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center