/// <summary> /// Retrieve the Multimedia device ID. If the entry 'DefaultTokenId' is defined in the registry /// under 'HKEY_CURRENT_USER\SOFTWARE\Microsoft\Speech\AudioOutput' then a multimedia device is looked /// for with this token. Otherwise, picks the default WAVE_MAPPER is returned. /// </summary> internal static int DefaultDeviceOut() { int device = -1; using (ObjectTokenCategory tokenCategory = ObjectTokenCategory.Create(@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Speech\AudioOutput")) { if (tokenCategory != null) { string deviceName; if (tokenCategory.TryGetString(_defaultTokenIdValueName, out deviceName)) { int pos = deviceName.IndexOf('\\'); if (pos > 0 && pos < deviceName.Length) { using (RegistryDataKey deviceKey = RegistryDataKey.Create(deviceName.Substring(pos + 1), Registry.LocalMachine)) { if (deviceKey != null) { device = AudioDeviceOut.GetDevicedId(deviceKey.Name); } } } } } } return(device); }
internal static int DefaultDeviceOut() { int result = -1; using (ObjectTokenCategory objectTokenCategory = ObjectTokenCategory.Create("HKEY_CURRENT_USER\\SOFTWARE\\Microsoft\\Speech\\AudioOutput")) { if (objectTokenCategory == null) { return(result); } string value; if (!objectTokenCategory.TryGetString("DefaultTokenId", out value)) { return(result); } int num = value.IndexOf('\\'); if (num <= 0) { return(result); } if (num < value.Length) { using (RegistryDataKey registryDataKey = RegistryDataKey.Create(value.Substring(num + 1), Registry.LocalMachine)) { if (registryDataKey != null) { return(AudioDeviceOut.GetDevicedId(registryDataKey.Name)); } return(result); } } return(result); } }