none
LPHMIDIOUT, HMIDIOUT, and MidiOutOpen problem in VS2005 RRS feed

  • Question

  • I'm trying to use midiOutOpen, which takes LPHMIDIOUT as its first argument. I have a declaration:

    HMIDIOUT hMidiOut

    in my class, and therefore pass the function:

    this->error = midiOutOpen (&hMidiOut, MIDIMAPPER, 0, 0, 0);

    however this gives me a compiler error:

    Error C2664: 'midiOutOpen' : cannot convert parameter 1 from 'cli::interior_ptr<Type>' to 'LPHMIDIOUT'

    I've tried all sorts of casts and searched MSDN but it doesn't give me any clues as to why it should throw an error, anyone have any ideas?

    IxxI

    Friday, March 10, 2006 1:43 PM

Answers

  • It seems that you cannot do this with hMidiOut declared in a class (and any combination of & and this->hMidiOut doesn't work either, so if you declare the function as returning HMIDIOUT, and declare HMIDIOUT test in the function, you can use &test, and then return test:

    this->hMidiOut = this->MyFunction();

    where MyFunction is:

    HMIDIOUT test;

    this->error = midiOutOpen(&test, MIDIMAPPER, 0, 0, 0);

    //error handling code

    return(test);

    Just in case anyone was interested .

    IxxI

    PS if anyone knows why this is I'd still be interested.

    Friday, March 10, 2006 4:11 PM

All replies

  • It seems that you cannot do this with hMidiOut declared in a class (and any combination of & and this->hMidiOut doesn't work either, so if you declare the function as returning HMIDIOUT, and declare HMIDIOUT test in the function, you can use &test, and then return test:

    this->hMidiOut = this->MyFunction();

    where MyFunction is:

    HMIDIOUT test;

    this->error = midiOutOpen(&test, MIDIMAPPER, 0, 0, 0);

    //error handling code

    return(test);

    Just in case anyone was interested .

    IxxI

    PS if anyone knows why this is I'd still be interested.

    Friday, March 10, 2006 4:11 PM
  • First thing to check: do you really need to use managed code? Wouldn't it be better if you moved this functionality into a normal class?

    As a workaround, you can hold the HMIDIOUT in an IntPtr.

    Saturday, March 11, 2006 11:53 PM
    Moderator