频道分类

delphi 设置系统静音取消系统静音

作者:admin 来源: 日期:2021/2/1 22:06:28 人气: 标签:

 
unit Unit1;

interface

uses
  Winapi.Windows, Winapi.Messages, System.SysUtils, System.Variants, System.Classes, Vcl.Graphics,
  Vcl.Controls, Vcl.Forms, Vcl.Dialogs, Vcl.StdCtrls;

type
  TForm1 = class(TForm)
    Button1: TButton;
    Button2: TButton;

    procedure Button1Click(Sender: TObject);
    procedure Button2Click(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;
  const
  APPCOMMAND_VOLUME_MUTE = $80000;
  WM_APPCOMMAND = $319;

implementation

{$R *.dfm}

procedure TForm1.Button1Click(Sender: TObject);
begin
SendMessageW(Handle,WM_APPCOMMAND,Handle,APPCOMMAND_VOLUME_MUTE);  //设置静音
end;


procedure TForm1.Button2Click(Sender: TObject);
begin
SendMessageW(Handle,WM_APPCOMMAND,Handle,APPCOMMAND_VOLUME_MUTE);//同样可以解除静音
end;

end.

上一篇:DELPHI 内进行音量控制及静音下一篇:没有资料