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编程获取系统当前进程、窗口句柄、文件属性

Delphi webbrowser1 execwb 复制 新建 打开

Delphi tms web core twebhttprequest使用

Delphi listview 导出excel txt vcf 单元

Delphi 用dde控制word

Delphi 系统服务状态获取管理员用户名

Delphi 增加/获得windows用户帐号

Delphi d10.x 在android 9及更高版本下使用Delphi获取设备序列号?

Delphi 通过http获取软件版本

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



打赏

取消

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

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

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

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

评论

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