請問各位大大,要如何鎖定鍵盤上全部的按鍵呢?(含系統及功能鍵) |
答題得分者是:mathewzhao
|
saam
初階會員 發表:61 回覆:75 積分:27 註冊:2003-03-03 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
### Disable Print Screen ###
http://www.bsdg.org/swag/PRINTING/0040.PAS.html
{
>If anyone could tell me how to disable [Print Screen] from within a
>text-based program, I would appreciate it. Thanks, - Jeff Napier, Another
>Company - For that you can trap int 5h(Print Screen interrupt) Here is a program I
wrote for someone on another network that will show you the basics of how
it can be done: nstn1410@fox.nstn.ca
}
PROGRAM DisableInt05h; { Dec 13/93, Greg Estabrooks. } USES CRT, { IMPORT Clrscr,KeyPressed. } DOS; { IMPORT SetIntVec,GetIntVec. } VAR OldInt05 :POINTER; { Holds the old address of INT 05h. } NumPressed :WORD; { The number of times PrtScr was pressed.} Misc :WORD; {$F } { Force FAR calls. } PROCEDURE NewInt05; ASSEMBLER; ASM Push DS { Push DS onto stack. } Mov AX,Seg @Data { Now point DS to our data segment. } Mov DS,AX Add NumPressed,1 { Add one to counter. } Pop DS { Pop DS off stack. } IRet { Force a return and pop flags off stack.} END;{NewInt05} {$F-} { Back to normal. } BEGIN NumPressed := 0; { Clear number count. } Clrscr; { Clear the screen. } GetIntVec($05,OldInt05); { Save Old Interrupt vector. } SetIntVec($05,@NewInt05); { Point to our trap. } Misc := 0; { Clear Counter. } REPEAT { Loop Until a key other than PrtScr is } { pressed. } GOTOXY(1,1); { Always show info at top corner. } Write(Misc:8,'... You have pressed PrtScr ',NumPressed:3,' times.'); INC(Misc); { Increase counter to show a change. } UNTIL KeyPressed; SetIntVec($05,OldInt05); { Restore Old Interrupt vector. } END.{DisableInt05h}--- --<-<-<@ 發表人 - hagar 於 2003/07/29 20:13:10 |
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
saam
初階會員 發表:61 回覆:75 積分:27 註冊:2003-03-03 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
saam
初階會員 發表:61 回覆:75 積分:27 註冊:2003-03-03 發送簡訊給我 |
|
william
版主 發表:66 回覆:2535 積分:3048 註冊:2002-07-11 發送簡訊給我 |
|
hagar
版主 發表:143 回覆:4056 積分:4445 註冊:2002-04-14 發送簡訊給我 |
|
mathewzhao
中階會員 發表:121 回覆:164 積分:67 註冊:2003-04-04 發送簡訊給我 |
Hi!saam兄
你要鎖住鍵盤,可以用Keyboard Hook這樣試一試:
// 點擊Button1 鎖住鍵盤
// 點擊Button2 解開鍵盤 ...
hKeyHook: Integer;
...
function KeyHook(iCode: Integer; wParam: wParam; Key: lParam): LRESULT; stdcall;
begin
if iCode < 0 then
CallNextHookEx(hKeyHook, iCode, wParam, Key);
Result := 1;
end; procedure TForm1.Button1Click(Sender: TObject);
begin
hKeyHook := SetWindowsHookEx(WH_KEYBOARD, KeyHook, HInstance, 0);
end; procedure TForm1.Button2Click(Sender: TObject);
begin
UnHookWindowsHookEx(hKeyHook);
hKeyHook := 0;
end;
|
mathewzhao
中階會員 發表:121 回覆:164 積分:67 註冊:2003-04-04 發送簡訊給我 |
Hi!saam兄
剛才忘了一個問題:
系統鍵在調用WH_KEYBOARD Hook之前就已經被處理了,在WH_KEYBOARD HOOK 中無法處理,可以如下試一試:
( 我使用delphi5 )
...
const
WH_KEYBOARD_LL = 13;
...
var
hKeyHook: Integer;
hKeyHookwin98:integer;
...
function KeyHook(iCode: Integer; wParam: wParam; Key: lParam): LRESULT; stdcall;
begin
if iCode < 0 then
CallNextHookEx(hKeyHook, iCode, wParam, Key);
Result := 1;
end; procedure TForm1.Button1Click(Sender: TObject);
var
temp:integer;
begin
if Win32Platform=VER_PLATFORM_WIN32_WINDOWS then //win98
begin
SystemParametersInfo(Spi_screensaverrunning,1,@temp,0);
hKeyHookwin98 := SetWindowsHookEx(WH_KEYBOARD, KeyHook, HInstance, 0);
end
else // win2000
begin
hKeyHook := SetWindowsHookEx(WH_KEYBOARD_LL, KeyHook, HInstance, 0);
end;
end; procedure TForm1.Button2Click(Sender: TObject);
var
temp:integer;
begin
if Win32Platform=VER_PLATFORM_WIN32_WINDOWS then
begin
SystemParametersInfo(spi_screensaverrunning,0,@temp,0);
UnHookWindowsHookEx(hKeyHookwin98);
hKeyHookwin98:=0;
end
else
begin
UnHookWindowsHookEx(hKeyHook);
hKeyHook := 0;
end;
end; 發表人 - mathewzhao 於 2003/08/01 20:02:40
|
saam
初階會員 發表:61 回覆:75 積分:27 註冊:2003-03-03 發送簡訊給我 |
|
5997
一般會員 發表:1 回覆:7 積分:1 註冊:2003-01-14 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |