禁止Windows NT/2000/XP/2003的Ctrl + Alt + Del热键
元旦,哪里也没去
送一个代码吧,LY可不是轻易给人写代码的
下面的方法适合任何Windows NT平台(4.0以上)(至少目前的WinNT都能支持)
NT4,2000,XP,2003全部OK的,而且没有窗口闪烁,呵呵,编译后的DLL才16K,好用得很的
别问我怎么Inject DLL到EXE呀,嘻嘻:)
元旦快乐,新年新气象~~~
library SASWinHook;
{
SASWinHook disable Windows NT/2000/XP/2003 Ctrl + Alt + Del hotkey by hook
copyrights by Liu Yang LYSoft http://lysoft.7u7.net 2006.1.1
usage: only need to inject this dll to WinLogon.exe
}
uses Windows, Messages;
{$R *.res}
var
FHandle: THandle;
OldAppProc: Pointer;
function HookProc(hHandle: THandle; uMsg: Cardinal;
wParam, lParam: Integer): LRESULT; stdcall;
var K, C: Word; // wndproc
begin
if uMsg = WM_HOTKEY then
begin
K := HIWORD(lParam);
C := LOWORD(lParam);
// press Ctrl + Alt + Del
if (C and VK_CONTROL<>0) and (C and VK_MENU <>0) and ( K = VK_DELETE)
then Exit; // disable Ctrl + Alt + Del
end;
Result := CallWindowProc(OldAppProc, hHandle,
uMsg, wParam, lParam);
end;
procedure EntryPointProc(Reason: Integer);
begin
case reason of
DLL_PROCESS_ATTACH:
begin // hook SAS window wndproc
FHandle := FindWindow('SAS window class', 'SAS window');
if not IsWindow(FHandle) then
begin
FHandle := 0;
Exit; // is window found?
end;
// save old wndproc
OldAppProc := Pointer(GetWindowLong(FHandle, GWL_WNDPROC));
// set new wndproc
SetWindowLong(FHandle, GWL_WNDPROC, Cardinal(@HookProc));
end;
DLL_PROCESS_DETACH:
begin
if FHandle > 0 then
begin // unhook
if Assigned(OldAppProc) then
SetWindowLong(FHandle, GWL_WNDPROC, LongInt(OldAppProc));
OldAppProc := nil;
end;
end;
end;
end;
begin
OldAppProc := nil;
FHandle := 0;
DllProc := @EntryPointProc;
EntryPointProc(DLL_PROCESS_ATTACH);
end.