使用C#静音Windows卷 [英] Mute Windows Volume using C#

查看:209
本文介绍了使用C#静音Windows卷的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人知道如何使用C#编程静音Windows XP的音量?

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屋!

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