I have been trying to make Global Keyboard hook program in visual C++ that writes keystrokes to a file "log.txt"..I am new to windows programming and i have gone through the msdn library to get an understanding of hooks....I think i have understood the concept theoretically but when i implement the code, it doesn't seem towork..The compiler doesn't show any error in both the DLL file and EXE file....Moreover the text file "log.txt" never gets created...
Here are the code files
First the DLL file
__declspec(dllexport) LRESULT CALLBACK KeyProc(int nCode, WPARAM wParam, LPARAM lParam)
if((wParam==VK_SPACE)||(wParam==VK_RETURN)||(wParam>=0x2f ) &&(wParam<=0x100))
fwrite(&ch,1,1,fp); // copy character to log file
return CallNextHookEx(g_hhk, nCode, wParam, lParam);
----Now the EXE file:
static HINSTANCE hinstDLL;
static HHOOK hhookkb;
int WINAPI WinMain(HINSTANCE hInstance1,HINSTANCE hPrevInstance,LPSTR lpCmdLine,int nShowCmd)
hinstDLL=LoadLibrary(TEXT("C:\\Documents and Settings\\Attar Singh\\My Documents\\Visual Studio 2008\\Projects\\key\\Debug\\key.dll"));
This program is giving me nightmares...Any sort of help will be greatly appreciated...thanks in advance...!!