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