Exemple #1
0
        private IAudioEndpointVolume GetAudioEndpointVolume()
        {
            MMDeviceEnumeratorClass devEnum = new MMDeviceEnumeratorClass();
            IMMDevice endPoint;

            devEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eConsole, out endPoint);
            Marshal.ReleaseComObject(devEnum);

            Guid IID_IAudioEndpointVolume = new Guid(IID.IAudioEndpointVolume);
            tag_inner_PROPVARIANT prop    = new tag_inner_PROPVARIANT();
            IntPtr ppInterface;

            endPoint.Activate(ref IID_IAudioEndpointVolume, CLSCTX_ALL, ref prop, out ppInterface);
            IAudioEndpointVolume endPointVol = Marshal.GetObjectForIUnknown(ppInterface) as IAudioEndpointVolume;

            return(endPointVol);
        }
        private IAudioEndpointVolume GetAudioEndpointVolume()
        {
            MMDeviceEnumeratorClass devEnum = new MMDeviceEnumeratorClass();
            IMMDevice endPoint;
            devEnum.GetDefaultAudioEndpoint(EDataFlow.eRender, ERole.eConsole, out endPoint);
            Marshal.ReleaseComObject(devEnum);

            Guid IID_IAudioEndpointVolume = new Guid(IID.IAudioEndpointVolume);
            tag_inner_PROPVARIANT prop = new tag_inner_PROPVARIANT();
            IntPtr ppInterface;
            endPoint.Activate(ref IID_IAudioEndpointVolume, CLSCTX_ALL, ref prop, out ppInterface);
            IAudioEndpointVolume endPointVol = Marshal.GetObjectForIUnknown(ppInterface) as IAudioEndpointVolume;

            return endPointVol;
        }