这里介绍一下使用API函数创建系统热键! 主要实现单个热键与复合热键的注册! unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs; type TForm1 = class(TForm) procedure FormCreate(Sender: TObject); procedure FormDestroy(Sender: TObject); private { Private declarations } procedure WMHotKey(var Msg: TWMHotKey); message WM_HOTKEY; public { Public declarations } end; var Form1: TForm1; implementation {$R *.dfm} var HotKeyId,HotKeyId2: Integer; procedure TForm1.FormCreate(Sender: TObject); begin HotKeyId:= GlobalAddAtom(PChar('Control+Enter')); HotKeyId2:=GlobalAddAtom(PChar('F1')); RegisterHotKey(Handle,HotKeyId,MOD_CONTROL,VK_RETURN); RegisterHotKey(Handle,HotKeyId2,0,VK_F1); end; //也可以通过override窗口函数来实现热键消息的处理 procedure TForm1.WMHotKey(var Msg: TWMHotKey); begin if Msg.HotKey = HotKeyId2 then ShowMessage('F1'); if Msg.HotKey = HotKeyId then ShowMessage('Ctrl+Enter'); end; procedure TForm1.FormDestroy(Sender: TObject); begin //注销热键 UnRegisterHotKey(handle,HotKeyId); GlobalDeleteAtom(HotKeyId); UnRegisterHotKey(handle,HotKeyId2); GlobalDeleteAtom(HotKeyId2); end; end.