SetWindowsHookEx will nicht :-((
-
So das mit meiner DLL funzt ja endlich

Hier der Source:#define MAKE_DLL // INCLUDES ////////////////////////////////////////////////////////////// #include <windows.h> #include <fstream> #include "dll.h" // DEFINES /////////////////////////////////////////////////////////////// // CONSTANTS ///////////////////////////////////////////////////////////// // GLOBALS /////////////////////////////////////////////////////////////// #pragma data_seg ("shared") int iNumInstances = 0; int iKeystrokes[255] = {0}; #pragma data_seg () #pragma comment(linker,"/SECTION:shared,RWS") // PROTOTYPES //////////////////////////////////////////////////////////// LRESULT CALLBACK KeyboardHookProc(int, WPARAM, LPARAM); void OutputKeystrokes(); // VARIABLES ///////////////////////////////////////////////////////////// HINSTANCE hDllInstance; HHOOK hKeyboardHook; // METHODS /////////////////////////////////////////////////////////////// // FUNCTIONS ///////////////////////////////////////////////////////////// int APIENTRY DllMain(HINSTANCE hInstance, DWORD fdwReason, PVOID pvReserved) { hDllInstance = hInstance; return TRUE; } EXPORT BOOL CALLBACK InstallHooks(void) { hKeyboardHook = SetWindowsHookEx(WH_KEYBOARD,(HOOKPROC)KeyboardHookProc,hDllInstance,0 ); if (hKeyboardHook == NULL) { return FALSE; } return TRUE; } EXPORT BOOL CALLBACK UnInstallHooks(void) { OutputKeystrokes(); return UnhookWindowsHookEx(hKeyboardHook); } LRESULT CALLBACK KeyboardHookProc(int nCode,WPARAM wParam,LPARAM lParam) { if(nCode < 0) return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam); // Verhindern das eine Nachricht mehrmals verarbeitet wird. if(nCode == HC_ACTION) { // Prüfen ob die Taste nicht gedrückt gehalten wurde. // Wenn dies der Fall ist, ist das 31. Bit _nicht_ gesetzt. if (!(lParam&0x40000000)) { iKeystrokes[wParam]++; } } return CallNextHookEx(hKeyboardHook, nCode, wParam, lParam); } void OutputKeystrokes() { std::ofstream out("c:\\kbhook.txt"); for (int i='A'; i<='Z'; i++) { out << (char)i << " = " << iKeystrokes[i] << "\n"; } } //////////////////////////////////////////////////////////////////////////Und "dll.h"
#ifdef __cplusplus #define EXPORT extern "C" __declspec (dllexport) #else #define EXPORT __declspec (dllexport) #endif EXPORT BOOL CALLBACK InstallHooks(void); EXPORT BOOL CALLBACK UnInstallHooks(void);Aber er will den Hook nicht installieren

Kann jemand erkennen an was das liegen kann?Danke im voraus,
Mr. DLL