Keyboard Hook Problem (seems verbally unsolvable)

  • Thread starter Daniel von Fersen
  • Start date
D

Daniel von Fersen

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);

}
 
J

John Carson

Daniel von Fersen said:
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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,767
Messages
2,569,571
Members
45,045
Latest member
DRCM

Latest Threads

Top