怎样编程才能达到这样的效果:无论怎样调音量图标里volume的滑杆,系统音量只能限定在指定的一个范围内?即改变系统最大音量值

解决方案 »

  1.   

    看看《windows 程序设计》第二十二章 里面有详细的关于这方面的东东/
      

  2.   

    你看一下下面这篇文章,应该帮助会很大的:
    http://asp.6to23.com/nowcan/tech/cb_volume.htm
      

  3.   

    你看看这里有:Audio Mixer Functions are a set of functions that control the routing of audio lines to a destination device for playing or recording. They can also control volume and other effects.http://www.codeproject.com/audio/admixer.asp?target=volume%7Csound
      

  4.   

    多写个判断就可以了啊:const long m_vconstMax=4000;
    const long m_vconstMin=-4000;
    long m_valume= volumeEdit.GetVolume ();if(m_valume>m_vconstMax)
    {
        m_valume=m_vconstMax;
    }if( m_valume<m_vconstMin)
    {
        m_valume=m_vconstMin

      
        MyWinamp.Pause ();     MyWinamp.SetVolume(m_valume); 
     
        MyWinamp.Run (); 
      

  5.   

    给焦急等待的人的福音,两个函数一看就明白了:
    (要include "mmsystem.h"和link "winmm.lib")void CVolumeDlg::SetVolume( const DWORD dwVolume )
    {
        MMRESULT                        result;
        HMIXER                          hMixer;
        MIXERLINE                       ml   = {0};
        MIXERLINECONTROLS               mlc  = {0};
        MIXERCONTROL                    mc   = {0};
        MIXERCONTROLDETAILS             mcd  = {0};
        MIXERCONTROLDETAILS_UNSIGNED    mcdu = {0};
        // get a handle to the mixer device
        result = mixerOpen(&hMixer, MIXER_OBJECTF_MIXER, 0, 0, 0);
        if (MMSYSERR_NOERROR == result)
        {
            ml.cbStruct        = sizeof(MIXERLINE);
            ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;        // get the speaker line of the mixer device
            result = mixerGetLineInfo((HMIXEROBJ) hMixer, &ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
            if (MMSYSERR_NOERROR == result)
            {
                mlc.cbStruct      = sizeof(MIXERLINECONTROLS);
                mlc.dwLineID      = ml.dwLineID;
                mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
                mlc.cControls     = 1;
                mlc.pamxctrl      = &mc;
                mlc.cbmxctrl      = sizeof(MIXERCONTROL);            // get the volume controls associated with the speaker line
                result = mixerGetLineControls((HMIXEROBJ) hMixer, &mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
                if (MMSYSERR_NOERROR == result)
                {
                    mcdu.dwValue    = dwVolume;                mcd.cbStruct    = sizeof(MIXERCONTROLDETAILS);
                    mcd.hwndOwner   = 0;
                    mcd.dwControlID = mc.dwControlID;
                    mcd.paDetails   = &mcdu;
                    mcd.cbDetails   = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
                    mcd.cChannels   = 1;                // set the volume
                    result = mixerSetControlDetails((HMIXEROBJ) hMixer, &mcd, MIXER_SETCONTROLDETAILSF_VALUE);
                    if (MMSYSERR_NOERROR == result)
                        AfxMessageBox("Volume changed!");
                    else
                        AfxMessageBox("mixerSetControlDetails() failed");
                }
                else
                    AfxMessageBox("mixerGetLineControls() failed");
            }
            else
                AfxMessageBox("mixerGetLineInfo() failed");
        
            mixerClose(hMixer);
        }
        else
            AfxMessageBox("mixerOpen() failed");
    }//====================================================================DWORD CVolumeDlg::GetVolume( void )
    {
        DWORD                           dwVolume = -1;
        MMRESULT                        result;
        HMIXER                          hMixer;
        MIXERLINE                       ml   = {0};
        MIXERLINECONTROLS               mlc  = {0};
        MIXERCONTROL                    mc   = {0};
        MIXERCONTROLDETAILS             mcd  = {0};
        MIXERCONTROLDETAILS_UNSIGNED    mcdu = {0};
        // get a handle to the mixer device
        result = mixerOpen(&hMixer, 0, 0, 0, MIXER_OBJECTF_HMIXER);
        if (MMSYSERR_NOERROR == result)
        {
            ml.cbStruct        = sizeof(MIXERLINE);
            ml.dwComponentType = MIXERLINE_COMPONENTTYPE_DST_SPEAKERS;        // get the speaker line of the mixer device
            result = mixerGetLineInfo((HMIXEROBJ) hMixer, &ml, MIXER_GETLINEINFOF_COMPONENTTYPE);
            if (MMSYSERR_NOERROR == result)
            {
                mlc.cbStruct      = sizeof(MIXERLINECONTROLS);
                mlc.dwLineID      = ml.dwLineID;
                mlc.dwControlType = MIXERCONTROL_CONTROLTYPE_VOLUME;
                mlc.cControls     = 1;
                mlc.pamxctrl      = &mc;
                mlc.cbmxctrl      = sizeof(MIXERCONTROL);            // get the volume controls associated with the speaker line
                result = mixerGetLineControls((HMIXEROBJ) hMixer, &mlc, MIXER_GETLINECONTROLSF_ONEBYTYPE);
                if (MMSYSERR_NOERROR == result)
                {
                    mcd.cbStruct    = sizeof(MIXERCONTROLDETAILS);
                    mcd.hwndOwner   = 0;
                    mcd.dwControlID = mc.dwControlID;
                    mcd.paDetails   = &mcdu;
                    mcd.cbDetails   = sizeof(MIXERCONTROLDETAILS_UNSIGNED);
                    mcd.cChannels   = 1;                // get the volume
                    result = mixerGetControlDetails((HMIXEROBJ) hMixer, &mcd, MIXER_SETCONTROLDETAILSF_VALUE);
                    if (MMSYSERR_NOERROR == result)
                        dwVolume = mcdu.dwValue;
                    else
                        AfxMessageBox("mixerGetControlDetails() failed");
                }
                else
                    AfxMessageBox("mixerGetLineControls() failed");
            }
            else
                AfxMessageBox("mixerGetLineInfo() failed");
        
            mixerClose(hMixer);
        }
        else
            AfxMessageBox("mixerOpen() failed");    return (dwVolume);
    }