Keyboard Hook Problem (seems verbally unsolvable)

Discussion in 'C++' started by Daniel von Fersen, May 2, 2004.

  1. Hello,
    I have a very very big problem.
    I try to set up a keyboard hook that captures keystrokes from every
    application, but it seems not to work. I'm using Borland C++, but the
    SetWindowsHookEx Function always returns NULL,

    if you know an answer, pleaaaaase tell me, i would really appreciate that!


    Code:
    ----------------------------------
    #include <vcl.h>
    #include <stdio.h>
    #include <process.h>
    #include <iostream.h>


    #include "Unit1.h"

    #pragma package(smart_init)
    #pragma resource "*.dfm"
    TForm1 *Form1;

    static HHOOK hhook = 0, hhookMsg=0;
    static HINSTANCE hInst;
    LRESULT CALLBACK TastatureingabeErfolgt(HWND hDlg,int code, WPARAM wParam,
    LPARAM lParam);

    __fastcall TForm1::TForm1(TComponent* Owner)
    : TForm(Owner)
    {
    }

    LRESULT CALLBACK TastatureingabeErfolgt(HWND hDlg,int code, WPARAM wParam,
    LPARAM lParam)
    {

    return CallNextHookEx(hhook, code, wParam, lParam);
    }


    void __fastcall TForm1::Button1Click(TObject *Sender)
    {

    hhook = SetWindowsHookEx(2, (HOOKPROC)TastatureingabeErfolgt, hInst,
    (DWORD)NULL);
    if(hhook==NULL)
    MessageBox( NULL,
    "Unable to install hook",
    "Error!",
    MB_OK);

    }
     
    Daniel von Fersen, May 2, 2004
    #1
    1. Advertising

  2. Daniel von Fersen

    John Carson Guest

    "Daniel von Fersen" <> wrote in message
    news:c71jb2$dvc$06$-online.com
    > Hello,
    > I have a very very big problem.
    > I try to set up a keyboard hook that captures keystrokes from every
    > application, but it seems not to work. I'm using Borland C++, but the
    > SetWindowsHookEx Function always returns NULL,
    >
    > if you know an answer, pleaaaaase tell me, i would really appreciate
    > that!


    This is off-topic here. Try a Windows newsgroup, e.g.,

    microsoft.public.vc.language
    or
    comp.os.ms-windows.programmer.win32


    --
    John Carson
    1. To reply to email address, remove donald
    2. Don't reply to email address (post here instead)
     
    John Carson, May 2, 2004
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?iso-8859-1?Q?S=F8ren_Lund?=

    Unsolvable problem

    =?iso-8859-1?Q?S=F8ren_Lund?=, Jul 26, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    341
    =?iso-8859-1?Q?S=F8ren_Lund?=
    Jul 26, 2004
  2. Julie Lerman
    Replies:
    16
    Views:
    706
    Julie Lerman
    Jan 28, 2006
  3. Luc The Perverse

    Windows Keyboard Hook via JNI

    Luc The Perverse, Oct 31, 2006, in forum: Java
    Replies:
    13
    Views:
    1,717
    Luc The Perverse
    Nov 9, 2006
  4. Michael Torrie

    Re: Keyboard hook in linux

    Michael Torrie, Jan 13, 2013, in forum: Python
    Replies:
    0
    Views:
    149
    Michael Torrie
    Jan 13, 2013
  5. Replies:
    0
    Views:
    163
Loading...

Share This Page