change volume win32 c++

user37875 picture user37875 · Mar 31, 2009 · Viewed 38.5k times · Source

How would I go about changing the sound volume in c++ win32? Also how would I mute/unmute it? Thanks for the help!

Answer

Irwin picture Irwin · Mar 31, 2009

Use the waveOutSetVolume API.

Here's an example:

  DWORD dwVolume;

  if (waveOutGetVolume(NULL, &dwVolume) == MMSYSERR_NOERROR)
    waveOutSetVolume(NULL, 0); // mute volume

  // later point in code, to unmute volume...
  waveOutSetVolume(NULL, dwVolume);