win7 下声音屏蔽利用了令一套声音架构,与xp的不相同,一下是屏蔽本进程声音代码,,但是没达到效果,求高手指点。。。
HRESULT hr = S_OK;
CoInitialize(NULL);
CComPtr<IMMDeviceEnumerator> spEnumerator;
hr = CoCreateInstance( __uuidof(MMDeviceEnumerator), NULL, CLSCTX_ALL, __uuidof(IMMDeviceEnumerator), (void**)&spEnumerator );
CComPtr<IMMDevice> spDevice;
hr = spEnumerator->GetDefaultAudioEndpoint( eRender, eMultimedia , &spDevice );
// IAudioEndpointVolume *endpointVolume;
// hr = spDevice->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_INPROC_SERVER, NULL, reinterpret_cast<void **>(&endpointVolume));
// endpointVolume->SetMute(TRUE,&AudioSessionVolumeCtx);
// endpointVolume->SetMasterVolumeLevel(0,&AudioSessionVolumeCtx);
CComPtr<IAudioSessionManager> spAudioSessionManager;
hr = spDevice->Activate( __uuidof(IAudioSessionManager), CLSCTX_ALL, NULL, (void**)&spAudioSessionManager );
CComPtr<IAudioSessionControl> spIAudioSessionControl;
spAudioSessionManager->GetAudioSessionControl(&GUID_NULL,FALSE,&spIAudioSessionControl);
CComPtr<ISimpleAudioVolume> spSimpleAudioVolume;
spIAudioSessionControl->QueryInterface((__uuidof(ISimpleAudioVolume), &spSimpleAudioVolume));
spSimpleAudioVolume->SetMute(TRUE, &GUID_NULL);
hr = spSimpleAudioVolume->SetMasterVolume(0, &GUID_NULL); // 静音
spSimpleAudioVolume->SetMute(TRUE, &GUID_NULL);
[注意]传递专业知识、拓宽行业人脉——看雪讲师团队等你加入!