procedure TForm1.Button1Click(Sender: TObject); {设置键盘钩子} begin EnableKeyHook; //设置钩子 Button1.Enabled:=False; Button2.Enabled:=True; Button3.Enabled:=True; button4.Enabled:=True; Panel1.Caption:='键盘钩子已经设置'; end; procedure TForm1.Button2Click(Sender: TObject); begin DisableKeyHook; //卸载钩子 Button1.Enabled:=True; Button2.Enabled:=False; Button3.Enabled:=False; Button4.Enabled:=False; Panel1.Caption:='键盘钩子已经设置'; end;