C#得到主音量电平/ precent [英] C# get master volume level/precent
问题描述
我得到这个code静音/取消静音的主音量
I got this code to mute/unmute the master volume
private const int APPCOMMAND_VOLUME_MUTE = 0x80000;
private const int WM_APPCOMMAND = 0x319;
[DllImport("user32.dll")]
public static extern IntPtr SendMessageW(IntPtr hWnd, int Msg, IntPtr wParam, IntPtr lParam);
SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle, (IntPtr)APPCOMMAND_VOLUME_MUTE);
我想知道我怎么能得到主音量电平/ precent,因为我想知道如果声音已静音与否。
I would to know how can I get the master volume level/precent because I want to know if the sound is already muted or not.
编辑: 要不然我想分裂静音/取消静音,所以我将有两个功能 - 一个用于静音和一个用于取消静音
or else I would like to split the mute/unmute sound so I will have two functions - one for mute and one for unmute.
感谢
推荐答案
我无法为所有的Windows版本做。(XP,VISTA和7)
虽然,我通过使用外部程序,如的NirCmd 做到了这一点,并发出命令我必要的。
I could not do it for all Windows versions (xp, vista & 7).
Though, I achieved it by used external programs, such as NirCmd, and sent the command I needed.
不是那么好解决方案,但它没有解决我的问题。
not so good solution but it did solve my problem.
这篇关于C#得到主音量电平/ precent的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!