怎吗截取CTRL+ALT+DEL(不是做坏事)(150分)

  • 主题发起人 主题发起人 och.ocx
  • 开始时间 开始时间
O

och.ocx

Unregistered / Unconfirmed
GUEST, unregistred user!
; 如题。
 
下面的过程可以使系统键生效或失效:

type
TKeyState = ( kbOn, kbOff );

procedure SetSystemKey( value : TKeyState );
var
NoUse : integer;
begin
case value of
kbOn : SystemParametersInfo( SPI_SCREENSAVERRUNNING, 0, @NoUse, 0);
kbOff : SystemParametersInfo( SPI_SCREENSAVERRUNNING, 1, @NoUse, 0);
end;
end;
 
Sunset兄说的对,用这个办法屏蔽不错。

但想截取就不那么容易了,95怎么说至少也是自称
抢占式多任务,那么容易让你截取了,BG岂不丢人?

我看就从ScreenSaver的原理入手去研究,说不定
搞出一些东东来。
 
想要截取Ctrl+Alt+Delte可以做一个程序, 把他的优先级Priority设置成最高(0)
程序中循环使用PeekMessage来截获键盘消息, 如果不是Ctrl+Alt+Delte就转发下去
若是进行处理。
上述只是一个想法,未经过测试
 
估计不行,原因还是95号称抢占式多任务,
优先级设成0也“抢”不过核心。

另外说一句,SetWindowHookEx是不行的。
 
先将Ctrl+Alt+shift 屏蔽
再用SetWindowHookEx,不知行不行?
 
高!建议试试!
 
在DELPHI中如何使用SetWindowHookEx函数?
 
下面是Delphi windows.pas中SetWindowsHookEx的声明
function SetWindowsHookEx(idHook: Integer;
lpfn: TFNHookProc; hmod: HINST;
dwThreadId: DWORD): HHOOK; stdcall;

下面是VC中对SetWindowsHookEx的帮助

HHOOK SetWindowsHookEx( int idHook,
// type of hook to install

HOOKPROC lpfn,
// address of hook procedure

HINSTANCE hMod,
// handle of application instance

DWORD dwThreadId
// identity of thread to install hook for

);

Parameters
idHook

Specifies the type of hook procedure to be installed. This parameter can be one of the following values: Value
Description

WH_CALLWNDPROC
Installs a hook procedure that monitors messages before the system sends them to the destination window procedure. For more information, see the CallWndProc hook procedure.

WH_CALLWNDPROCRET
Installs a hook procedure that monitors messages after they have been processed by the destination window procedure. For more information, see the CallWndRetProc hook procedure.

WH_CBT
Installs a hook procedure that receives notifications useful to a computer-based training (CBT) application. For more information, see the CBTProc hook procedure.

WH_DEBUG
Installs a hook procedure useful for debugging other hook procedures. For more information, see the DebugProc hook procedure.

WH_GETMESSAGE
Installs a hook procedure that monitors messages posted to a message queue. For more information, see the GetMsgProc hook procedure.

WH_JOURNALPLAYBACK
Installs a hook procedure that posts messages previously recorded by a WH_JOURNALRECORD hook procedure. For more information, see the JournalPlaybackProc hook procedure.

WH_JOURNALRECORD
Installs a hook procedure that records input messages posted to the system message queue. This hook is useful for recording macros. For more information, see the JournalRecordProc hook procedure.

WH_KEYBOARD
Installs a hook procedure that monitors keystroke messages. For more information, see the KeyboardProc hook procedure.

WH_MOUSE
Installs a hook procedure that monitors mouse messages. For more information, see the MouseProc hook procedure.

WH_MSGFILTER
Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar. For more information, see the MessageProc hook procedure.

WH_SHELL
Installs a hook procedure that receives notifications useful to shell applications. For more information, see the ShellProc hook procedure.

WH_SYSMSGFILTER
Installs a hook procedure that monitors messages generated as a result of an input event in a dialog box, message box, menu, or scroll bar. The hook procedure monitors these messages for all applications in the system. For more information, see the SysMsgProc hook procedure.



lpfn

Points to the hook procedure. If the dwThreadId parameter is zero or specifies the identifier of a thread created by a different process, the lpfn parameter must point to a hook procedure in a dynamic-link library (DLL). Otherwise, lpfn can point to a hook procedure in the code associated with the current process.

hMod

Identifies the DLL containing the hook procedure pointed to by the lpfn parameter. The hMod parameter must be set to NULL if the dwThreadId parameter specifies a thread created by the current process and if the hook procedure is within the code associated with the current process.

dwThreadId

Specifies the identifier of the thread with which the hook procedure is to be associated. If this parameter is zero, the hook procedure is associated with all existing threads.

Return Values
If the function succeeds, the return value is the handle of the hook procedure.

If the function fails, the return value is NULL.

Remarks
An error may occur if the hMod parameter is NULL and the dwThreadId parameter is zero or specifies the identifier of a thread created by another process.

Calling the CallNextHookEx function to chain to the next hook procedure is optional, but it is highly recommended; otherwise, other applications that have installed hooks will not receive hook notifications and may behave incorrectly as a result. You should call CallNextHookEx unless you absolutely need to prevent the notification from being seen by other applications.

Before terminating, an application must call the UnhookWindowsHookEx function to free system resources associated with the hook.

The scope of a hook depends on the hook type. Some hooks can be set only with system scope; others can also be set for only a specific thread, as shown in the following list: Hook
Scope

WH_CALLWNDPROC
Thread or system

WH_CALLWNDPROCRET
Thread or system

WH_CBT
Thread or system

WH_DEBUG
Thread or system

WH_GETMESSAGE
Thread or system

WH_JOURNALPLAYBACK
System only

WH_JOURNALRECORD
System only

WH_KEYBOARD
Thread or system

WH_MOUSE
Thread or system

WH_MSGFILTER
Thread or system

WH_SHELL
Thread or system

WH_SYSMSGFILTER
System only



For a specified hook type, thread hooks are called first, then system hooks.

The system hooks are a shared resource, and installing one affects all applications. All system hook functions must be in libraries. System hooks should be restricted to special-purpose applications or to use as a development aid during application debugging. Libraries that no longer need a hook should remove the hook procedure.
 
;谢谢各位大虾的热情回答!
但是现在我只能为一人加积分(不知为什吗现在不能给每人平均分配?)
我用Sunset老兄的方法加上SetWindowsHookEx(...),然后结合GetKeyboardState(...)
&SetKeyboardState(...)大概实现了要求。但是CTRL+ALT+DEL按下时机不同时,
可能截取不到。
我该怎吗分配积分呢?
 
给版主写信.
 
分别截取CTRL、ALT、DEL每次判别其它键是否按下·OK?
 
后退
顶部