<p>How can I change the master volume level? Using this code</p>

<pre><code>[DllImport ("winmm.dll")]
public static extern int waveOutSetVolume (IntPtr hwo, uint dwVolume);

waveOutSetVolume (IntPtr.Zero, (((uint)uint.MaxValue &amp; 0x0000ffff) | ((uint)uint.MaxValue &lt;&lt; 16)));
</code></pre>

<p>I can set the wave volume but if the master volume is too low this won't have any effect.</p>

<p>Thanks for any help.</p>

For the master volume (for Vista and above), that would be:
ISimpleAudioVolume::SetMasterVolume
As explained
here
, you may refer to the section:
Core Audio APIs in Windows Vista
for more.
This call is not a Media Foundation call but a WASAPI (Windows Audio Session API) call:
 ISimpleAudioVolume::SetMasterVolume (The SetMasterVolume method sets the master volume level for the audio session.)
This may be difficult however to make the UI of the Media Center reflect the new sound level set by that call, as this
thread illustrates
it.
For windows Xp, you can study this
script
and maybe
this other script
.
Audio Library
might also be of interest.
There is also this old
Audio Project
which hasa master volume part:
```
```
BOOL CVolumeDlg::amdInitialize()
{
    ASSERT(m_hMixer == NULL);

    // get the number of mixer devices present in the system
    m_nNumMixers = ::mixerGetNumDevs();

    m_hMixer = NULL;
    ::ZeroMemory(&m_mxcaps, sizeof(MIXERCAPS));

    m_strDstLineName.Empty();
    m_strVolumeControlName.Empty();
    m_dwMinimum = 0;
    m_dwMaximum = 0;
    m_dwVolumeControlID = 0;

    // open the first mixer
    // A "mapper" for audio mixer devices does not currently exist.
    if (m_nNumMixers != 0)
    {
        if (::mixerOpen(&m_hMixer,
                        0,
                        reinterpret_cast<DWORD>(this->GetSafeHwnd()),
                        NULL,
                        MIXER_OBJECTF_MIXER | CALLBACK_WINDOW)
            != MMSYSERR_NOERROR)
        {
            return FALSE;
        }

        if (::mixerGetDevCaps(reinterpret_cast<UINT>(m_hMixer),
                              &m_mxcaps, sizeof(MIXERCAPS))
            != MMSYSERR_NOERROR)
        {
            return FALSE;
        }
    }

    return TRUE;
}

BOOL CVolumeDlg::amdUninitialize()
{
    BOOL bSucc = TRUE;

    if (m_hMixer != NULL)
    {
        bSucc = (::mixerClose(m_hMixer) == MMSYSERR_NOERROR);
        m_hMixer = NULL;
    }

    return bSucc;
}

BOOL CVolumeDlg::amdGetMasterVolumeControl()
{
    if (m_hMixer == NULL)
    {
        return FALSE;
    }

    // get dwLineID
    MIXERLINE mxl;
    mxl.cbStruct = sizeof(MIXERLINE);
    mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;
    if (::mixerGetLineInfo(reinterpret_cast<HMIXEROBJ>(m_hMixer),
                           &mxl,
                           MIXER_OBJECTF_HMIXER |
                           MIXER_GETLINEINFOF_COMPONENTTYPE)
        != MMSYSERR_NOERROR)
    {
        return FALSE;
    }

    // get dwControlID
    MIXERCONTROL mxc;
    MIXERLINECONTROLS mxlc;
    mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
    mxlc.dwLineID = mxl.dwLineID;
    mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
    mxlc.cControls = 1;
    mxlc.cbmxctrl = sizeof(MIXERCONTROL);
    mxlc.pamxctrl = &mxc;
    if (::mixerGetLineControls(reinterpret_cast<HMIXEROBJ>(m_hMixer),
                               &mxlc,
                               MIXER_OBJECTF_HMIXER |
                               MIXER_GETLINECONTROLSF_ONEBYTYPE)
        != MMSYSERR_NOERROR)
    {
        return FALSE;
    }

    // store dwControlID
    m_strDstLineName = mxl.szName;
    m_strVolumeControlName = mxc.szName;
    m_dwMinimum = mxc.Bounds.dwMinimum;
    m_dwMaximum = mxc.Bounds.dwMaximum;
    m_dwVolumeControlID = mxc.dwControlID;

    return TRUE;
}

BOOL CVolumeDlg::amdGetMasterVolumeValue(DWORD &dwVal) const
{
    if (m_hMixer == NULL)
    {
        return FALSE;
    }

    MIXERCONTROLDETAILS_UNSIGNED mxcdVolume;
    MIXERCONTROLDETAILS mxcd;
    mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
    mxcd.dwControlID = m_dwVolumeControlID;
    mxcd.cChannels = 1;
    mxcd.cMultipleItems = 0;
    mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
    mxcd.paDetails = &mxcdVolume;
    if (::mixerGetControlDetails(reinterpret_cast<HMIXEROBJ>(m_hMixer),
                                 &mxcd,
                                 MIXER_OBJECTF_HMIXER |
                                 MIXER_GETCONTROLDETAILSF_VALUE)
        != MMSYSERR_NOERROR)
    {
        return FALSE;
    }

    dwVal = mxcdVolume.dwValue;

    return TRUE;
}

BOOL CVolumeDlg::amdSetMasterVolumeValue(DWORD dwVal) const
{
    if (m_hMixer == NULL)
    {
        return FALSE;
    }

    MIXERCONTROLDETAILS_UNSIGNED mxcdVolume = { dwVal };
    MIXERCONTROLDETAILS mxcd;
    mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
    mxcd.dwControlID = m_dwVolumeControlID;
    mxcd.cChannels = 1;
    mxcd.cMultipleItems = 0;
    mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
    mxcd.paDetails = &mxcdVolume;
    if (::mixerSetControlDetails(reinterpret_cast<HMIXEROBJ>(m_hMixer),
                                 &mxcd,
                                 MIXER_OBJECTF_HMIXER |
                                 MIXER_SETCONTROLDETAILSF_VALUE)
        != MMSYSERR_NOERROR)
    {
        return FALSE;
    }

    return TRUE;
}
```
```