Пример #1
0
            private static WinXpDllInterface.MIXERINFO InnerGetMixerInfo()
            {
                WinXpDllInterface.MIXERLINE    mxl = new WinXpDllInterface.MIXERLINE();
                WinXpDllInterface.LINECONTROLS mlc = new WinXpDllInterface.LINECONTROLS();
                mxl.cbStruct = (uint)Marshal.SizeOf(typeof(WinXpDllInterface.MIXERLINE));
                mlc.cbStruct = (uint)Marshal.SizeOf(typeof(WinXpDllInterface.LINECONTROLS));

                WinXpDllInterface.mixerGetLineInfo(0, ref mxl, WinXpDllInterface.MIXER_OBJECTF_MIXER | WinXpDllInterface.MIXER_GETLINEINFOF_DESTINATION);

                mlc.dwLineID  = mxl.dwLineID;
                mlc.cControls = mxl.cControls;
                mlc.cbmxctrl  = (uint)Marshal.SizeOf(typeof(WinXpDllInterface.MIXERCONTROL));
                mlc.pamxctrl  = Marshal.AllocHGlobal((int)(mlc.cbmxctrl * mlc.cControls));

                WinXpDllInterface.mixerGetLineControls(0, ref mlc, WinXpDllInterface.MIXER_OBJECTF_MIXER | WinXpDllInterface.MIXER_GETLINECONTROLSF_ALL);

                WinXpDllInterface.MIXERINFO rtn = new WinXpDllInterface.MIXERINFO();

                for (int i = 0; i < mlc.cControls; i++)
                {
                    WinXpDllInterface.MIXERCONTROL mxc = (WinXpDllInterface.MIXERCONTROL)Marshal.PtrToStructure((IntPtr)((int)mlc.pamxctrl + (int)mlc.cbmxctrl * i), typeof(WinXpDllInterface.MIXERCONTROL));
                    switch (mxc.dwControlType)
                    {
                    case WinXpDllInterface.MIXERCONTROL_CONTROLTYPE_VOLUME:
                        rtn.volumeCtl = mxc.dwControlID;
                        rtn.minVolume = mxc.Bounds.lMinimum;
                        rtn.maxVolume = mxc.Bounds.lMaximum;
                        break;

                    case WinXpDllInterface.MIXERCONTROL_CONTROLTYPE_MUTE:
                        rtn.muteCtl = mxc.dwControlID;
                        break;
                    }
                }

                Marshal.FreeHGlobal(mlc.pamxctrl);

                return(rtn);
            }
Пример #2
0
            private static bool GetIsMuted()
            {
                bool result = false;

                InvokeTryCatch("WinXpVolumeOperate.GetIsMuted", () =>
                {
                    WinXpDllInterface.MIXERINFO mixer  = InnerGetMixerInfo();
                    WinXpDllInterface.MIXERDETAILS mcd = new WinXpDllInterface.MIXERDETAILS();
                    mcd.cbStruct    = Marshal.SizeOf(typeof(WinXpDllInterface.MIXERDETAILS));
                    mcd.dwControlID = (int)mixer.muteCtl;
                    mcd.cChannels   = 1;
                    mcd.cbDetails   = 4;
                    mcd.paDetails   = Marshal.AllocHGlobal((int)mcd.cbDetails);

                    WinXpDllInterface.mixerGetControlDetails(0, ref mcd, WinXpDllInterface.MIXER_GETCONTROLDETAILSF_VALUE | WinXpDllInterface.MIXER_OBJECTF_MIXER);
                    int rtn = Marshal.ReadInt32(mcd.paDetails);
                    Marshal.FreeHGlobal(mcd.paDetails);

                    result = rtn != 0;
                });
                return(result);
            }