.
.
int randomCheck;
int keystate=0;
#pragma data_seg()
#pragma comment(linker, "/section:SHARED,RWS")
HHOOK g_hhk;
struct HookStruct{
int vkCode,scanCode,flags,time,dwExtraInfo;
}hs;
extern "C" __declspec(dllexport)
LRESULT CALLBACK KeyProc(int nCode, WPARAM wParam, LPARAM lParam)
{
//do only if its really a key event
if(nCode == HC_ACTION){
//copy data lParam pointes to (lParam is defined as long but is in fact a pointer)
memcpy(&hs,(void*)lParam,sizeof(HookStruct));
//257->keyup 256->keydown 49 is keycode for key 1 and
//scancode 2 for key 1 is released while ctrl and shift is pressed, for key 2 the scancode is 3, key 3 its 4...
if(wParam == 257 && hs.vkCode == 49 && hs.scanCode == 2){
keystate = (keystate) ? 0:1;
}
}
return CallNextHookEx(g_hhk, nCode, wParam, lParam);
}
......
......
//folowing added to your constructor
//load its self to use exported function and tell windows to use it for keystrokes on a low level
HMODULE hLib = LoadLibrary("senderella.dll");
HOOKPROC proc = (HOOKPROC)GetProcAddress(hLib, "KeyProc");
g_hhk=SetWindowsHookEx(WH_KEYBOARD_LL,proc,hLib,0);
.
.
.
i think with visual c you don't need to export the function like i have done. (mingw here)
thanx for the inspiration, now i have the quickest solofunction ever
