Q: Cast LPHMIXER to HMIXER in Windows mmeapi I'm trying to figure out how to call the mixerOpen() and mixerClose() functions using C++ on the Windows 10 platform. I'm using cl.exe as the compiler.
The mixerOpen() function fills an LPHMIXER with a handle to the mixer object. When I call the mixerClose() function, it expects a HMIXER instead of the LPHMIXER.
Question: How do I properly cast an LPHMIXER to an HMIXER, so I can call the mixerClose() function?
I tried using static_cast and dynamic_cast, but they both failed. For example:
UINT retval;
LPHMIXER mixer;
retval = mixerOpen(mixer, 0, NULL, 0, MIXER_OBJECTF_AUX);
cout << endl << "Return value: " << retval;

HMIXER hmixer = dynamic_cast<HMIXER>(mixer);
mixerClose(hmixer);


... shows the error:

the operand of a pointer dynamic_cast must be a pointer to a complete class type


A: LPHMIXER is just a typedef for HMIXER *. The sequence to open/use/close the mixer object is:
HMIXER hmixer;
MMRESULT retval = mixerOpen(&hmixer, 0, NULL, 0, MIXER_OBJECTF_AUX);
if(retval != MMSYSERR_NOERROR) { /* error */ }

/* use hmixer */

retval = mixerClose(hmixer);

