Windows 7中的音量控制 [英] Volume control in Windows 7

查看:105
本文介绍了Windows 7中的音量控制的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一小段代码用于更改Windows XP的波形量。我用了



I have a small piece of code that I used to change the wave volume of on windows XP. I used

[DllImport("winmm.dll")]
public static extern int waveOutGetVolume(IntPtr hwo, out uint dwVolume);

[DllImport("winmm.dll")]
public static extern int waveOutSetVolume(IntPtr hwo, uint dwVolume);





当我在windwos 7上使用此代码并更改音量





When I use this code on windwos 7. and change volume

int NewVolume = ((ushort.MaxValue / 10) * currentVolume);
// Set the same volume for both the left and the right channels
uint NewVolumeAllChannels = (((uint)NewVolume & 0x0000ffff) | ((uint)NewVolume << 16));
// Set the volume
                waveOutSetVolume(IntPtr.Zero, NewVolumeAllChannels);





音量没有变化。当我打开win7的主音量窗口时,我可以看到音量级别栏发生了变化,但音量变化没有发生。



我知道还有其他方法可以在Windows 7上做同样的事情,但我只是想知道为什么音量不会改变,如果我的函数调用能够设置音量栏到所需的级别?



The volume is not getting changed. When i opened the master volume window of win7 I could see the volume level bar getting changed but the volume change was not happening.

I know there are other ways to do the same thing on windows 7 but I was just wondering why the volume is not changing if my function call is able to set the volume bar to the required level?

推荐答案





自Windows Vista / 7 MS改变了访问控制音量,混音器等,它被称为coreaudio API。

以下是一些链接,我相信你可以用它来解决问题:



http://msdn.microsoft.com/en-us /library/ms678715.aspx?ppud=4 [ ^ ]

Vista Core Audio API主音量控制 [ ^ ]

http://rongchaua.net/blog/c-adjust-master-volume-in-vista-and-windows-7/ [ ^ ]



您还可以使用或查看NAudio Wrapper:

http://naudio.codeplex.com/ [ ^ ]



祝你好运;)

问候
Hi,

since Windows Vista/7 MS changed the access to control volume, mixers, etc. and it's called the coreaudio API.
Here are some links, I'm sure you can work something out with it:

http://msdn.microsoft.com/en-us/library/ms678715.aspx?ppud=4[^]
Vista Core Audio API Master Volume Control[^]
http://rongchaua.net/blog/c-adjust-master-volume-in-vista-and-windows-7/[^]

You can also use or have a look at NAudio Wrapper:
http://naudio.codeplex.com/[^]

Good Luck ;)
Regards


我体验了waveOutSetVolume和waveOutGetVolume的功能仅更改当前应用程序的卷输出而不是主系统卷。因此,音量升高或降低,但您没有看到主音量滚动条上的任何更改。打开搅拌机,看看那里。
I made the experience that the waveOutSetVolume and waveOutGetVolume Functions only change the volume ouput of your current application and not the master system volume. therefore the volume is raised or lowered but you dont see any change on the master volume scrollbar. open the mixer and take a look there.


这篇关于Windows 7中的音量控制的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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