🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #14341

Lowlevelkeyboard hook question ?

#14341
From: Martin C
Date: Sun, 17 Aug 2003 23:21
46 lines
2598 bytes
I am trying to use low level keyboard hook using the following function, to
disable some key combinations like ALT+ESC,  ALT+TAB...etc.

So far the ALT+TAB and the ALT+ESCAPE are disabled while the CONTROL + ALT +
DELETE disable line is not working, in other words if I pressed
ctrl+alt+delete the system will still show the task manager, can some one
help me please and tell me what I am missing here in this code? or what I am
doing wrong?

Another question, the low level keyboard hook is good for Windows NT4 SP3
and up (based on Microsoft documentation), so what is the alternative
function to achieve the my task (disabling some key combinations) in Windows
95, 98...

thanks in advance

LRESULT CALLBACK LowLevelKeyboardProc(int nCode, WPARAM wParam, LPARAM
lParam)
{
   BOOL fEatKeystroke = FALSE;

   if (nCode == HC_ACTION) {
      switch (wParam)
      { case WM_KEYDOWN:  case WM_SYSKEYDOWN:
        case WM_KEYUP:    case WM_SYSKEYUP:
         PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) lParam;
         fEatKeystroke =
            ((p->vkCode == VK_TAB) && ((p->flags & LLKHF_ALTDOWN) != 0)) ||
            ((p->vkCode == VK_ESCAPE) && ((p->flags & LLKHF_ALTDOWN) != 0))
||

            //Nothing happens here !!!
            ((p->vkCode == VK_DELETE) && ((p->flags & LLKHF_ALTDOWN) != 0)
&& (GetKeyState(VK_CONTROL))  ||


            ((p->vkCode == VK_ESCAPE) && ((GetKeyState(VK_CONTROL) & 0x8000)
!= 0));
         break;
      }
   }
   return(fEatKeystroke ? 1 : CallNextHookEx(NULL, nCode, wParam,
          lParam));
}
//--------------------------------------------------------------------------
-
Technical Details
Message-ID: <3f3f73be@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,8e2edf04fa0c971c,start
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-17 05:38:06 PST
From: "Martin C" <martinc@aol.com>
Newsgroups: borland.public.cppbuilder.nativeapi
Subject: Lowlevelkeyboard hook question ?
Date: Sun, 17 Aug 2003 15:21:56 -0800
Lines: 48
Organization: V Safe
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
NNTP-Posting-Host: 62.135.27.159
Message-ID: <3f3f73be@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1061123006 62.135.27.159 (17 Aug 2003 05:23:26 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!small1.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail