以下是注册系统全局热键的例子,以及注册全局原子表的例子!<br><br>procedure TForm1.FormCreate(Sender: TObject);<br>Var TmpID:Integer;<br>begin<br> TmpID:=GlobalFindAtom('MyHotkey');<br> if TmpID=0 then //查找全局原子.如果返回值不为0,则说明这个全局原子已经被注册;<br> id:=GlobalAddAtom('MyHotkey')<br> else<br> ID:=TmpID;<br><br> TmpID:=GlobalFindAtom('MyHotkey1');<br> if TmpID=0 then<br> id1:=GlobalAddAtom('MyHotkey1')<br> else<br> id1:=TmpID;<br><br> TmpID:=GlobalFindAtom('MyHotkey2');<br> if TmpID=0 then<br> id2:=GlobalAddAtom('MyHotkey2')<br> else<br> id2:=TmpID;<br> RegisterHotKey(Handle, id, MOD_CONTROL, VK_F1); //注册热键:Ctrl+F1<br> RegisterHotKey(Handle, id1, MOD_CONTROL, VK_F2);//注册热键:Ctrl+F2<br> RegisterHotKey(Handle, id2, MOD_CONTROL, VK_F3);//注册热键:Ctrl+F3<br>end;<br><br>procedure TForm1.FormDestroy(Sender: TObject);<br>begin<br> UnregisterHotKey(Handle,ID);//释放热键Ctrl+F1<br> UnregisterHotKey(Handle,ID1);//释放热键Ctrl+F2<br> UnregisterHotKey(Handle,ID2);//释放热键Ctrl+F3<br> GlobalDeleteAtom(ID); //删除全局原子ID<br> GlobalDeleteAtom(ID1);//删除全局原子ID1<br> GlobalDeleteAtom(ID2);//删除全局原子ID2<br>end;<br><br>procedure TForm1.WMHotKey(var Msg: TWMHotKey);<br>begin<br> if msg.HotKey=ID then //热键Ctrl+F1的消息.<br> ShowMessage('Ctrl+F1!')<br> else if Msg.HotKey=ID1 then //热键Ctrl+F2的消息.<br> ShowMessage('Ctrl+F2!')<br> else if Msg.HotKey=ID2 then //热键Ctrl+F3的消息.<br> ShowMessage('Ctrl+F3!');<br>end;<br><br><br>