delphi 控制音量 静音的类


本文整理自网络,侵删。

 
unit ttSound;

interface

uses winapi.windows, winapi.Messages;

type
  SimpleSoundControl = class
    class procedure Mute(); static;
    class procedure VolumeUp(); static;
    class procedure VolumeDown(); static;
  end;

implementation

{ SimpleSoundControl }

class procedure SimpleSoundControl.Mute;
begin
  keybd_event(VK_VOLUME_MUTE, MapVirtualKey(VK_VOLUME_MUTE, 0), KEYEVENTF_EXTENDEDKEY, 0);
  keybd_event(VK_VOLUME_MUTE, MapVirtualKey(VK_VOLUME_MUTE, 0), KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
end;

class procedure SimpleSoundControl.VolumeDown;
begin
  keybd_event(VK_VOLUME_DOWN, MapVirtualKey(VK_VOLUME_DOWN, 0), KEYEVENTF_EXTENDEDKEY, 0);
  keybd_event(VK_VOLUME_DOWN, MapVirtualKey(VK_VOLUME_DOWN, 0), KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
end;

class procedure SimpleSoundControl.VolumeUp;
begin
  keybd_event(VK_VOLUME_UP, MapVirtualKey(VK_VOLUME_UP, 0), KEYEVENTF_EXTENDEDKEY, 0);
  keybd_event(VK_VOLUME_UP, MapVirtualKey(VK_VOLUME_UP, 0), KEYEVENTF_EXTENDEDKEY or KEYEVENTF_KEYUP, 0);
end;

end.

来源:https://www.cnblogs.com/cb168/p/6367310.html

相关阅读 >>

Delphi 跳出循环的几种方法

Delphi listview排序

Delphi antiemupeb

Delphi getforegroundwindow 与 getactivewindow 的区别

Delphi unigui unicheckbox勾选

Delphi 动态数组的释放

Delphi 服务端日志记录

Delphi inttostr 将“整数型”转换成“字符型”

Delphi 对指定dbgrid进行排序

Delphi的tfilestream 内存流

更多相关阅读请进入《Delphi》频道 >>



打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...