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...
Page 1 of 1
Error C2065
#2
Posted 10 July 2011 - 09:56 PM
I am very new too, but if you look at the errors the function "BOOL __declspec(dllexport)installhook()" contains "KeyboardProc" that is defined later in "LRESULT __declspec(dllexport)__stdcall KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)".
Try to put "LRESULT __declspec(dllexport)__stdcall KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)" before "BOOL __declspec(dllexport)installhook()".
Try to put "LRESULT __declspec(dllexport)__stdcall KeyboardProc(int nCode, WPARAM wParam, LPARAM lParam)" before "BOOL __declspec(dllexport)installhook()".
This post has been edited by xilolee: 10 July 2011 - 09:56 PM
INCONCEIVABLE! - You keep using that word. I do not think it means what you think it means.
italian guides - guide della sezione italiana --- come ottenere aiuto
italian support - sezione italiana --- scaricare la lista server --- i filtri ip
ottenere id alto --- aprire le porte nel router --- recuperare file corrotti
Sembra talco ma non č serve a darti l'allegrIa! Se lo lanci e poi lo respiri ti dā subito l'allegrIa!
italian guides - guide della sezione italiana --- come ottenere aiuto
italian support - sezione italiana --- scaricare la lista server --- i filtri ip
ottenere id alto --- aprire le porte nel router --- recuperare file corrotti
Sembra talco ma non č serve a darti l'allegrIa! Se lo lanci e poi lo respiri ti dā subito l'allegrIa!

Page 1 of 1










Sign In
Register
