以编程方式更改播放设备XP [英] Change playback device programmatically xp

查看:103
本文介绍了以编程方式更改播放设备XP的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何更改当前使用的声卡(xp),而无需进入控制面板>声音设备>选择播放设备。

How can i change which is the current sound card in use (xp), without going into control panel>sounds devices> choose playback device.

任何语言都可以足够的文件或批处理文件,只是我必须每天更换设备播放约50次,并且每次都必须加载控制面板才很麻烦。

any language would suffice, or batch file, just that i have to change the device for playback about 50 times a day and its a pain having to load control panel each time.

如何?

推荐答案

要在Windows XP中设置默认的声音播放设备,可以更改以下注册表项的值:

To set the default sound playback device in Windows XP, you can change the value of the following registry key:

HKEY_CURRENT_USER\Software\Microsoft\Multimedia\Sound Mapper\Playback

鉴于现有的配置以及您希望从安装中选择的所有设备的配置,可能最容易做的就是选择每种声音在声音和音频设备属性控制面板中一次播放一个设备,然后将此注册表项的设置导出到文件中。因此,如果您希望在3个声音播放设备之间进行选择,那么最终将得到3个独立的.REG文件,每个文件对应于其中一个播放设备。否则,您将必须以编程方式实时生成注册表项文件。

Probably the easiest thing to do, given an existing configuration with all of the devices you wish to be able to select from installed, is to select each of the sound playback devices one at a time in the Sound and Audio Device Properties control panel and export the settings for this registry key to a file. So, if you had 3 sound playback devices that you wanted to be able to choose between, you would end up with 3 separate .REG files, each corresponding to one of the playback devices. Otherwise, you will have to generate the registry entry files programmatically on the fly.

生成了这些.REG文件后,只需双击其中的一个即可。资源管理器会将它们包含的信息插入注册表中的相应位置,这将选择相应的播放设备。您可以轻松地以编程方式执行这些注册表脚本。在C#中,您可能会使用 System.Diagnostics.Process.Start 并传递您要生效的.REG文件的位置。或者,您可以编写一个简单的批处理文件,无需进行确认即可静默导入注册条目文件:

Once you've generated these .REG files, simply double-clicking on one of them in Explorer will insert the information that they contain into the appropriate location in the registry, which will select the corresponding playback device. You can easily execute these registry scripts programmatically. In C#, you might use something like System.Diagnostics.Process.Start and pass the location of the .REG file that you want to take effect. Alternatively, you could write a simple batch file that silently imports the registration entries file without requiring confirmation:

@echo off
%windir%\regedit.exe /s ExternalSpeakers.reg

在申请中不用多说此解决方案并手动编辑注册表,您对Windows安装可能造成的任何破坏承担全部责任。

It goes without saying that in applying this solution and manually editing your registry, you take full responsibility for any havoc that you may wreak with your Windows installation.

(我知道Windows XP解决方案是asker正在寻找,但对于任何将来的Google员工,请注意,这不适用于Windows Vista或更高版本,后者使用核心音频API 来管理这些设置。请参见此问题以寻求解决方案。)

(I understand that a Windows XP solution is what the asker is looking for, but for any future Googlers, note that this will NOT work with Windows Vista or later, which uses the Core Audio APIs to manage these settings instead. See this question for a solution.)

这篇关于以编程方式更改播放设备XP的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆