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);
[招生]科锐逆向工程师培训(2024年11月15日实地,远程教学同时开班, 第51期)