Пример #1
0
        /// <summary>
        ///     Alle Abspielgeräte anzeigen
        /// </summary>
        /// <returns></returns>
        public static List <string> GetPlaybackNames()
        {
            //Ergebnis
            var list       = new List <string>();
            var waveOutCap = new Win32.WAVEOUTCAPS();

            //Anzahl Devices
            var num = Win32.waveOutGetNumDevs();

            for (var i = 0; i < num; i++)
            {
                var hr = Win32.waveOutGetDevCaps(i, ref waveOutCap, Marshal.SizeOf(typeof(Win32.WAVEOUTCAPS)));
                if (hr == (int)Win32.HRESULT.S_OK)
                {
                    list.Add(waveOutCap.szPname);
                }
            }

            //Fertig
            return(list);
        }
Пример #2
0
        /// <summary>
        /// GetWaveOutDeviceIdByName
        /// </summary>
        /// <param name="name"></param>
        /// <returns></returns>
        public static int GetWaveOutDeviceIdByName(string name)
        {
            //Anzahl Devices
            uint num = Win32.waveOutGetNumDevs();

            //WaveIn Struktur
            Win32.WAVEOUTCAPS caps = new Win32.WAVEOUTCAPS();
            for (int i = 0; i < num; i++)
            {
                Win32.HRESULT hr = (Win32.HRESULT)Win32.waveOutGetDevCaps(i, ref caps, Marshal.SizeOf(typeof(Win32.WAVEOUTCAPS)));
                if (hr == Win32.HRESULT.S_OK)
                {
                    if (caps.szPname == name)
                    {
                        //Gefunden
                        return(i);
                    }
                }
            }

            //Nicht gefunden
            return(Win32.WAVE_MAPPER);
        }