all_rays
asked on
KeyLogger Delphi
I have problem when using dll from http://www.freevbcode.com/ShowCode.Asp?ID=728, the author give an example in VB, when i try translate that code into Delphi, i found that my code doesn't work
could someone help me
thanks
this some part of my code
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function Hooked:boolean; external 'KTKbdHk.dll';
function HookKeyboard(Hwnd,MsgID:Ca rdinal):Lo ngInt; external 'KTKbdHk.dll';
function UnhookKeyboard:Boolean; external 'KTKbdHk.dll';
var
Form1: TForm1;
const
MessageAris=$11;
implementation
{$R *.dfm}
type
{$IFDEF WIN32}
WParameter = LongInt;
{$ELSE}
WParameter = Word;
{$ENDIF}
LParameter = LongInt;
{Declare a variable to hold the window procedure we are replacing}
var
OldWindowProc : Pointer;
function NewWindowProc(WindowHandle : hWnd;
TheMessage : WParameter;
ParamW : WParameter;
ParamL : LParameter) : LongInt; stdcall;
var tempRes : integer;
charRes : char;
keyboardState: TKeyboardState;
begin
{ Process the message of your choice here }
if TheMessage = MessageAris then
begin
// The application should enter this area when i press some key
// but it doesn't work, anyone know why?
end;
NewWindowProc := CallWindowProc(OldWindowPr oc,
WindowHandle,
TheMessage,
ParamW,
ParamL);
end;
procedure TForm1.Button1Click(Sender : TObject);
begin
if Hooked then
ShowMessage('Hooked');
if HookKeyboard(Button3.Handl e,MessageA ris)<>0 then
Button1.Enabled:=False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
OldWindowProc := Pointer(SetWindowLong(Butt on3.Handle ,GWL_WNDPR OC,longInt (@NewWindo wProc)));
Button1.Click;
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
UnhookKeyboard;
SetWindowLong(Button3.Hand le,GWL_WND PROC,LongI nt(OldWind owProc));
end;
procedure TForm1.Button2Click(Sender : TObject);
begin
if UnhookKeyboard then
Button1.Enabled:=True;
end;
could someone help me
thanks
this some part of my code
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
function Hooked:boolean; external 'KTKbdHk.dll';
function HookKeyboard(Hwnd,MsgID:Ca
function UnhookKeyboard:Boolean; external 'KTKbdHk.dll';
var
Form1: TForm1;
const
MessageAris=$11;
implementation
{$R *.dfm}
type
{$IFDEF WIN32}
WParameter = LongInt;
{$ELSE}
WParameter = Word;
{$ENDIF}
LParameter = LongInt;
{Declare a variable to hold the window procedure we are replacing}
var
OldWindowProc : Pointer;
function NewWindowProc(WindowHandle
TheMessage : WParameter;
ParamW : WParameter;
ParamL : LParameter) : LongInt; stdcall;
var tempRes : integer;
charRes : char;
keyboardState: TKeyboardState;
begin
{ Process the message of your choice here }
if TheMessage = MessageAris then
begin
// The application should enter this area when i press some key
// but it doesn't work, anyone know why?
end;
NewWindowProc := CallWindowProc(OldWindowPr
WindowHandle,
TheMessage,
ParamW,
ParamL);
end;
procedure TForm1.Button1Click(Sender
begin
if Hooked then
ShowMessage('Hooked');
if HookKeyboard(Button3.Handl
Button1.Enabled:=False;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
OldWindowProc := Pointer(SetWindowLong(Butt
Button1.Click;
end;
procedure TForm1.FormDestroy(Sender:
begin
UnhookKeyboard;
SetWindowLong(Button3.Hand
end;
procedure TForm1.Button2Click(Sender
begin
if UnhookKeyboard then
Button1.Enabled:=True;
end;
Why not use the Windows API directly? Do you need it to be a dll?
Try downloading this code - it should do what you want
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=7&txtCodeId=588
David
http://www.planet-source-code.com/vb/scripts/ShowCode.asp?lngWId=7&txtCodeId=588
David
ASKER
for calinutz, what do you mean with Windows API? could you give me some example code
thanks
thanks
ASKER
David, i have already download that link, but unfortunately it isn't what i want. actually i don't wont use timer anymore. i will be more apreciate if someone could correct my code above. thanks
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
hi Slick812, thanks for your answer. i think your library is better than what i have ever had before.
actually, i still confuse with windows hooking.
Could you help me to give some link or literature related with windows hooking, please send to my email at belum5menit@yahoo.com
For this session i will give this point to u
thanks
actually, i still confuse with windows hooking.
Could you help me to give some link or literature related with windows hooking, please send to my email at belum5menit@yahoo.com
For this session i will give this point to u
thanks
if you look in your windows API Help that comes with Delphi, for the index of word "Hooks", there is info here about hooking, you will need to click the >_> arrows at the top to advance to the next pages of that muti-page explanation
at the About web site for delphi there is a page about hooks at
http://delphi.about.com/library/bluc/text/uc063001a.htm
this gives some of the basics for hooks, and there is code there to look at
you may also go to the MSDN library on the web and look for hook info there
at the About web site for delphi there is a page about hooks at
http://delphi.about.com/library/bluc/text/uc063001a.htm
this gives some of the basics for hooks, and there is code there to look at
you may also go to the MSDN library on the web and look for hook info there