Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Jul 27th, 2004, 1:02 PM   #1
enigmaJ2J
Newbie
 
Join Date: Jul 2004
Posts: 1
Rep Power: 0 enigmaJ2J is on a distinguished road
Hello I am trying to create a program with c++ builder that hooks and blocks keyboard keys such as : ALT, winkey, delete , and etc.

I am posting there my program text but it is not full can someone help me

*.cpp file

//---------------------------------------------------------------------------
#include <vcl.h>
#include <windows.h>
#pragma hdrstop
#include "Unit1.h"
//---------------------------------------------------------------------------
#pragma package(smart_init)
#pragma resource "*.dfm"
TForm1 *Form1;
//---------------------------------------------------------------------------
LRESULT CALLBACK KeyboadProc(...)
{}
//---------------------------------------------------------------------------
__fastcall TForm1::TForm1(TComponent* Owner)
: TForm(Owner)
{
}
//---------------------------------------------------------------------------
void __fastcall TForm1::FormCreate(TObject *Sender)
{SetWindowsHookEx(WH_KEYBOARD,HOOKPROC(KeyboadProc()),hMod,0);
}
//---------------------------------------------------------------------------

*.h file

//---------------------------------------------------------------------------

#ifndef Unit1H
#define Unit1H
//---------------------------------------------------------------------------
#include <Classes.hpp>
#include <Controls.hpp>
#include <StdCtrls.hpp>
#include <Forms.hpp>
//---------------------------------------------------------------------------
class TForm1 : public TForm
{
__published: // IDE-managed Components
void __fastcall FormCreate(TObject *Sender);
private: // User declarations
HINSTANCE hMod;
public: // User declarations
__fastcall TForm1(TComponent* Owner);
LRESULT CALLBACK KeyboadProc();
};
//---------------------------------------------------------------------------
extern PACKAGE TForm1 *Form1;
//---------------------------------------------------------------------------
#endif

Pleae show me the right way someone
enigmaJ2J is offline   Reply With Quote
Old Jul 28th, 2004, 8:29 PM   #2
unknowen
Newbie
 
Join Date: Jun 2004
Posts: 11
Rep Power: 0 unknowen is on a distinguished road
If I corectly remember, to write a hook code you have to place it in dll and then call those functions from your program. Search msdn for these things.
msdn.microsoft.com
unknowen is offline   Reply With Quote
Old Jul 30th, 2004, 12:17 AM   #3
kurifu
Expert Programmer
 
kurifu's Avatar
 
Join Date: Jul 2004
Location: Halifax, Nova Scotia (Canada)
Posts: 784
Rep Power: 5 kurifu is on a distinguished road
Send a message via ICQ to kurifu Send a message via MSN to kurifu
Why not just look for the WM_CHAR event, or WM_KEYBOARD (or whatever) event and then stop processing that message when you are done with it.

Otherwise you will have to hook with a DLL file. Look it up on msdn, or thecodeproject.com.
__________________
Clifford Matthew Roche &lt;geek@cliffordroche.com&gt;
Web Hosting: http://www.crd-hosting.com
Consulting: http://www.crdev-consulting.com
kurifu is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 2:33 PM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC