使用 C# 静音 Windows 音量 [英] Mute Windows Volume using C#
本文介绍了使用 C# 静音 Windows 音量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
有人知道如何使用 C# 以编程方式将 Windows XP Volume 静音吗?
Anyone know how to programmatically mute the Windows XP Volume using C#?
推荐答案
为 P/Invoke 声明:
Declare this for P/Invoke:
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);
然后使用此行将声音静音/取消静音.
And then use this line to mute/unmute the sound.
SendMessageW(this.Handle, WM_APPCOMMAND, this.Handle, (IntPtr) APPCOMMAND_VOLUME_MUTE);
这篇关于使用 C# 静音 Windows 音量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文