I am new to windows programming, I was trying to compile the following code and it gives me the following errors:
C:\Program Files\Microsoft Visual Studio\MyProjects\hook\hook.cpp(14) : error C2065: 'KeyboardProc' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\hook\hook.cpp(22) : error C2373: 'KeyboardProc' : redefinition; different type modifiers
C:\Program Files\Microsoft Visual Studio\MyProjects\hook\hook.cpp(30) : error C2065: 'GetkeyState' : undeclared identifier
Error executing cl.exe.
/* CODE */
#include<windows.h>
static HHOOK hkb=NULL;
HANDLE h;
BOOL __stdcall DllMain(HANDLE hModule, DWORD ul_reason_for_call, LPVOID lpReserved)
{
h=hModule;
return TRUE;
}
BOOL __declspec(dllexport)installhook()
{
hkb=SetWindowsHookEx(WH_KEYBOARD, (HOOKPROC)KeyboardProc, (HINSTANCE)h,0);
if(hkb==NULL)
return FALSE;
return TRUE;
}
LRESULT __declspec(dllexport)__stdcall KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)
{
short int state;
if(nCode<0)
return CallNextHookEx(hkb, nCode, wParam, lParam);
if((nCode==HC_ACTION)&&((DWORD)lParam&0*40000000))
{
state=GetkeyState(VK_CAPITAL);
if((state&1)==0)
{
keybd_event(VK_CAPITAL,0,KEYEVENTF_EXTENDEDKEY,0);
keybd_event(VK_CAPITAL,0,KEYEVENTF_EXTENDEDKEY|KEYEVENTF_KEYUP,0);
}
}
return CallNextHookEx(hkb, nCode, wParam, lParam);
}
BOOL __declspec(dllexport) removehook()
{
return UnhookWindowsHookEx(hkb);
}
Can anyone please help me...