MFC Win7 master volume setting Sound Control

BOOL CAudioHelper::SetWin7AudioMasterFullVolume(void)
{
    HRESULT hr=NULL;
 
    double nVolume = (double)0;
    double newVolume=nVolume;
 
    CoInitialize(NULL);
    IMMDeviceEnumerator *deviceEnumerator = NULL;
    hr = CoCreateInstance(__uuidof(MMDeviceEnumerator), NULL, CLSCTX_INPROC_SERVER,
        __uuidof(IMMDeviceEnumerator), (LPVOID *)&deviceEnumerator);
    IMMDevice *defaultDevice = NULL;
 
    hr = deviceEnumerator->GetDefaultAudioEndpoint(eRender, eConsole, &defaultDevice);
    deviceEnumerator->Release();
    deviceEnumerator = NULL;
 
    IAudioEndpointVolume *endpointVolume = NULL;
    hr = defaultDevice->Activate(__uuidof(IAudioEndpointVolume),
        CLSCTX_INPROC_SERVER, NULL, (LPVOID *)&endpointVolume);
    defaultDevice->Release();
    defaultDevice = NULL;
 
    float fVolumeMin, fVolumeMax, fVolumeInc;
    endpointVolume->GetVolumeRange(&fVolumeMin, &fVolumeMax, &fVolumeInc);
    hr = endpointVolume->SetMasterVolumeLevel(fVolumeMax, NULL);
 
    endpointVolume->Release();
 
    return TRUE;
}

덧글

댓글 입력 영역


통계 위젯 (블랙)

034
134
410270