![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Newbie
Join Date: Jul 2004
Posts: 1
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#2 |
|
Newbie
Join Date: Jun 2004
Posts: 11
Rep Power: 0
![]() |
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 |
|
|
|
|
|
#3 |
|
Expert Programmer
|
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 <geek@cliffordroche.com> Web Hosting: http://www.crd-hosting.com Consulting: http://www.crdev-consulting.com |
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|