如何在WINDOWS2000下屏蔽WINDOWS键

hyz0912 2003-01-08 12:01:49
请问
使用DELPHI60,如何在WINDOWS2000下屏蔽WINDOWS键
...全文
56 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
singlesword 2003-01-12
  • 打赏
  • 举报
回复
不太可能吧?有这种事?
hyz0912 2003-01-12
  • 打赏
  • 举报
回复
实在对不起,系统不让我给你分,给多少都不行,如果你知道为什么,请告诉我,我一定会给你分的
hyz0912 2003-01-12
  • 打赏
  • 举报
回复
thank you1
jlj_jill 2003-01-08
  • 打赏
  • 举报
回复
unit Unit1;

interface

uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;

type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
CheckBox1: TCheckBox;
CheckBox2: TCheckBox;
CheckBox3: TCheckBox;
CheckBox4: TCheckBox;
CheckBox5: TCheckBox;
CheckBox6: TCheckBox;
CheckBox7: TCheckBox;
CheckBox8: TCheckBox;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form1: TForm1;

const
WH_KEYBOARD_LL = 13;
LLKHF_ALTDOWN = $00000020;

type
tagKBDLLHOOKSTRUCT = record
vkCode: DWORD;
scanCode: DWORD;
flags: DWORD;
time: DWORD;
dwExtraInfo: DWORD;
end;
KBDLLHOOKSTRUCT = tagKBDLLHOOKSTRUCT;
LPKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;
PKBDLLHOOKSTRUCT = ^KBDLLHOOKSTRUCT;

var
hhkLowLevelKybd: HHOOK;

function LowLevelKeyBoardProc(nCode: Integer; awParam: WPARAM; alParam: LPARAM): LRESULT; stdcall;


implementation

function LowLevelKeyBoardProc(nCode: Integer; awParam: WPARAM; alParam: LPARAM): LRESULT; stdcall;
var
fEatKeyStroke: Boolean;
p: PKBDLLHOOKSTRUCT;
begin
fEatKeystroke := False;
if nCode = HC_ACTION then
begin
case awParam of
WM_KEYDOWN,
WM_SYSKEYDOWN,
WM_KEYUP,
WM_SYSKEYUP:
begin
p := PKBDLLHOOKSTRUCT(alParam);
if ((p^.flags and LLKHF_ALTDOWN) <> 0) and ((GetKeyState(VK_CONTROL) and $8000) <> 0) then
fEatKeystroke := True;
if ((p^.flags and LLKHF_ALTDOWN) <> 0) and (p^.vkCode = VK_ESCAPE) then
fEatKeystroke := True;
if ((p^.flags and LLKHF_ALTDOWN) <> 0) and (p^.vkCode = VK_TAB) then
fEatKeystroke := True;
if ((p^.Flags and LLKHF_ALTDOWN) <> 0) and (p^.vkCode = VK_SPACE) then
fEatKeyStroke := True;
if ((GetKeyState(VK_CONTROL) and $8000) <> 0) and (p^.vkCode = VK_ESCAPE) then
fEatKeystroke := True;
if p^.vkCode = VK_LWIN then
fEatKeystroke := True;
end;
end;
end;
if fEatKeyStroke then
Result := 1
else
Result := CallNextHookEx(hhkLowLevelKybd, nCode, awParam, alParam);
end;

{$R *.DFM}

procedure TForm1.Button1Click(Sender: TObject);
begin
ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_HIDE);
hhkLowLevelKybd := SetWindowsHookEx(WH_KEYBOARD_LL, @LowLevelKeyboardProc, hInstance, 0);
Button1.Enabled := False;
Button2.Enabled := True;
end;

procedure TForm1.Button2Click(Sender: TObject);
begin
UnhookWindowsHookEx(hhkLowLevelKybd);
ShowWindow(FindWindow('Shell_TrayWnd', nil), SW_SHOW);
Button1.Enabled := True;
Button2.Enabled := False;
end;

end.

1,184

社区成员

发帖
与我相关
我的任务
社区描述
Delphi Windows SDK/API
社区管理员
  • Windows SDK/API社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧