Click here to Skip to main content
15,904,497 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: SetCurrentDirectory() not working?? Pin
uandrej9-Jan-03 9:56
uandrej9-Jan-03 9:56 
GeneralRe: SetCurrentDirectory() not working?? Pin
Ted Ferenc9-Jan-03 21:31
Ted Ferenc9-Jan-03 21:31 
GeneralRe: SetCurrentDirectory() not working?? Pin
Anonymous9-Jan-03 23:49
Anonymous9-Jan-03 23:49 
GeneralSDK - MAPI .oft Files Pin
Harald Diel9-Jan-03 6:02
Harald Diel9-Jan-03 6:02 
GeneralRe: SDK - MAPI .oft Files Pin
Harald Diel12-Jan-03 22:50
Harald Diel12-Jan-03 22:50 
QuestionHow to create a menu item on the fly Pin
ns9-Jan-03 5:25
ns9-Jan-03 5:25 
AnswerRe: How to create a menu item on the fly Pin
Michael Dunn9-Jan-03 5:35
sitebuilderMichael Dunn9-Jan-03 5:35 
Generalsetting up a keyboard system wide hook (contains the code, if you would like to see it...) Pin
Joan M9-Jan-03 5:00
professionalJoan M9-Jan-03 5:00 
Hello,

INTRODUCTION:
1. I'm trying to install a system wide keyboard hook in order to avoid some keystrokes.
2. I've implemented that static callback f(x) inside a DLL.
3. I call the DLL exported function from a service.
4. I'm sure that the service works right. (it's a SERVICE_WIN32_OWN_PROCESS service).
5. It seems that the callback function that has the hook it's called only one time!.

PROTOTYPE:
static LRESULT CALLBACK HookTeclatLL(int nCode,WPARAM wParam,LPARAM lParam);


CALL
hHookTeclat = SetWindowsHookEx(WH_KEYBOARD_LL, HookTeclatLL, hInstDLLSCT, NULL);
return (hHookTeclat != NULL); <code>the return value is not NULL</code>


CODE:
static LRESULT CALLBACK HookTeclatLL(int nCode,WPARAM wParam,LPARAM lParam)
{
  if (nCode == HC_ACTION)
  {
    switch (wParam)
    {
      case WM_KEYDOWN:
      case WM_SYSKEYDOWN:
      case WM_KEYUP:
      case WM_SYSKEYUP:
      {
        LPKBDLLHOOKSTRUCT p = (LPKBDLLHOOKSTRUCT)lParam;
        bool bDeleteKey = false;

        bDeleteKey =  ((p->vkCode == VK_RWIN) ||
                      (p->vkCode == VK_LWIN) ||
                      (p->vkCode == VK_ESCAPE) ||
                      (p->vkCode == VK_F1) || 
                      (p->vkCode == VK_F2) || 
                      (p->vkCode == VK_F3) || 
                      (p->vkCode == VK_F4) || 
                      (p->vkCode == VK_F5) || 
                      (p->vkCode == VK_F6) || 
                      (p->vkCode == VK_F7) || 
                      (p->vkCode == VK_F8) || 
                      (p->vkCode == VK_F9) || 
                      (p->vkCode == VK_F10) || 
                      (p->vkCode == VK_F11) || 
                      (p->vkCode == VK_F12) || 
                      (p->vkCode == VK_CANCEL) ||
                      (p->vkCode == VK_RBUTTON) || 
                      (p->vkCode == VK_PAUSE) ||
                      (p->vkCode == VK_SNAPSHOT) ||
                      (p->vkCode == VK_APPS) ||
                      (p->vkCode == VK_SCROLL));

        if (!bDeleteKey)
        {
          if ((p->flags & LLKHF_ALTDOWN) != 0)
          {
            bDeleteKey = (p->vkCode == VK_TAB);
          }

          if ((p->flags & MOD_WIN) != 0)
          {
            bDeleteKey = true;
          }
        }

        if (bDeleteKey) 
        {
          logEstat("\nELIMINANT\n");  <code>In order to monitor only</code>
          MessageBox(NULL,"ELIMINANT","",MB_SERVICE_NOTIFICATION); <code>In order to monitor only</code>
          return 1; <code>this should remove the key pressed...</code>
        }

        break;
      }
    }
  }

  return CallNextHookEx(hHookTeclat, nCode, wParam, lParam);
}

Do you know anything that I'm missing or that I have misunderstood or something?

The problems are:
1. I think that only one time its called that static callback f(x).
2. the keys are not removed.
3. It seems that the messageboxes never appear... even with the MB_SERVICE_NOTIFICATION...

Thank you in advance.
GeneralRe: setting up a keyboard system wide hook (contains the code, if you would like to see it...) Pin
Joan M9-Jan-03 5:15
professionalJoan M9-Jan-03 5:15 
GeneralNT Services and MFC Pin
henrik_stromberg9-Jan-03 4:49
henrik_stromberg9-Jan-03 4:49 
GeneralRe: NT Services and MFC Pin
Joan M9-Jan-03 5:03
professionalJoan M9-Jan-03 5:03 
GeneralRe: NT Services and MFC Pin
henrik_stromberg9-Jan-03 20:38
henrik_stromberg9-Jan-03 20:38 
GeneralRe: NT Services and MFC Pin
Carlos Antollini9-Jan-03 5:06
Carlos Antollini9-Jan-03 5:06 
QuestionLocking toolbars/control bars? Pin
Chris Hambleton9-Jan-03 3:57
Chris Hambleton9-Jan-03 3:57 
GeneralDAO DLLs Pin
Anthony B.9-Jan-03 3:42
Anthony B.9-Jan-03 3:42 
GeneralRe: DAO DLLs Pin
Carlos Antollini9-Jan-03 5:11
Carlos Antollini9-Jan-03 5:11 
QuestionPointer to multi-dimensional array? Pin
Dominik Reichl9-Jan-03 3:40
Dominik Reichl9-Jan-03 3:40 
AnswerRe: Pointer to multi-dimensional array? Pin
AlexO9-Jan-03 3:56
AlexO9-Jan-03 3:56 
GeneralRe: Pointer to multi-dimensional array? Pin
Dominik Reichl9-Jan-03 4:21
Dominik Reichl9-Jan-03 4:21 
Generalamutithreads server Pin
smallcoder9-Jan-03 2:27
smallcoder9-Jan-03 2:27 
GeneralPostThreadMessage? Pin
AlexO9-Jan-03 4:30
AlexO9-Jan-03 4:30 
GeneralRe: PostThreadMessage? Pin
smallcoder9-Jan-03 4:59
smallcoder9-Jan-03 4:59 
GeneralRe: PostThreadMessage? Pin
AlexO9-Jan-03 5:35
AlexO9-Jan-03 5:35 
GeneralRe: PostThreadMessage? Pin
AlexO9-Jan-03 5:38
AlexO9-Jan-03 5:38 
GeneralRe: PostThreadMessage? Pin
smallcoder9-Jan-03 6:41
smallcoder9-Jan-03 6:41 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.