Hej.
Min kode ser sådan her ud.
#include "windows.h"
#include "iostream"
HHOOK hHook;
HINSTANCE hInst;
//typedef struct {LPARAM lParam; WPARAM wParam; UINT message; HWND hwnd; } CWPSTRUCT, *PCWPSTRUCT;
LRESULT __declspec(dllexport)__stdcall CALLBACK CallWndProc(int nCode, WPARAM wParam, LPARAM lParam)
{
if(nCode >= 0)
{
CWPSTRUCT *msg = (CWPSTRUCT *)lParam;
switch(msg->message){
case WM_TIMER:
std::cout<<"WM_TIMER"<<std::endl;
break;
}
}
return CallNextHookEx(hHook, nCode, wParam, lParam );
}
BOOL __declspec(dllexport)__stdcall installhook()
{
hHook = SetWindowsHookEx(WH_GETMESSAGE, (HOOKPROC)CallWndProc,GetModuleHandle((LPCWSTR)TEXT("DLL Hook.dll")),0);
if(hHook == 0){
std::cout<<GetLastError()<<std::endl;
return false;
}
else
return true;
}
BOOL __declspec(dllexport) UnHook()
{
BOOL unhooked = UnhookWindowsHookEx(hHook);
return unhooked;
}
Kan det være fordi jeg skal bruge en anden hook type?