none
win7下!将本进程设置为静音!而且在合成器中可以看到本进程是静音的图标!但是仍然能听到声音!为什么?是不是后续还有什么步骤? RRS feed

  • 问题

  • 同样设置音量为零的话,也是如此!

    BOOL SetMute(BOOL bMute)
    {
    HMIXER hMixer;
    MIXERCONTROL mxc;
    MIXERLINE mxl;
    MIXERLINECONTROLS mxlc;
    MIXERCONTROLDETAILS mxcd;
    MIXERCONTROLDETAILS_SIGNED volStruct;
    MMRESULT mmr;

    //Sound Setting
    mmr = mixerOpen(&hMixer, 0, 0, 0, 0);
    if (mmr != MMSYSERR_NOERROR) return FALSE;

    // 初始化MIXERLINE结构体.
    ZeroMemory(&mxl, sizeof(MIXERLINE));
    mxl.cbStruct = sizeof(MIXERLINE);

    // 指出需要获取的通道,扬声器用MIXERLINE_COMPONENTTYPE_DST_SPEAKERS
    mxl.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;

    mmr = mixerGetLineInfo((HMIXEROBJ)hMixer, &mxl, MIXER_GETLINEINFOF_COMPONENTTYPE);
    if (mmr != MMSYSERR_NOERROR) return FALSE;

    // 取得控制器.
    ZeroMemory(&mxlc, sizeof(MIXERLINECONTROLS));
    mxlc.cbStruct = sizeof(MIXERLINECONTROLS);
    mxlc.dwLineID = mxl.dwLineID;
    mxlc.dwControlType = MIXERCONTROL_CONTROLTYPE_MUTE;
    mxlc.cControls = 1;
    mxlc.cbmxctrl = sizeof(mxc);
    mxlc.pamxctrl = &mxc;
    //mxc.cMultipleItems=0;

    ZeroMemory(&mxc, sizeof(MIXERCONTROL));
    mxc.cbStruct = sizeof(MIXERCONTROL);
    mmr = mixerGetLineControls((HMIXEROBJ)hMixer, &mxlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
    if (mmr != MMSYSERR_NOERROR) return FALSE;

    // 初始化MIXERCONTROLDETAILS结构体
    ZeroMemory(&mxcd, sizeof(MIXERCONTROLDETAILS));
    mxcd.cbStruct = sizeof(MIXERCONTROLDETAILS);
    mxcd.cbDetails = sizeof(MIXERCONTROLDETAILS_SIGNED);
    mxcd.dwControlID = mxc.dwControlID;
    mxcd.paDetails = &volStruct;
    mxcd.cChannels = 1;

    // 获得音量值
    volStruct.lValue = bMute;
    mmr = mixerSetControlDetails((HMIXEROBJ)hMixer, &mxcd, MIXER_SETCONTROLDETAILSF_VALUE);

    mixerClose(hMixer);
    return TRUE;
    }

    • 已移动 Helen Zhao 2012年4月25日 2:19 (发件人:Visual C++)
    2012年4月24日 8:50

全部回复

  • ddd22 你好!

    我将要把该帖移到“一般性问题讨论区”。因为在C++论坛,我们只讨论有关C++语言和编译器的问题。

    谢谢你的谅解!

    祝你好运!


    Helen Zhao [MSFT]
    MSDN Community Support | Feedback to us

    2012年4月25日 2:19