Trouble in keyboard grabber`s KeyboardProc procedure 

Hi!
I try to write keyboard grabber, but in my DLL in KeyboardProc when I write name of pressed key in file I got error - "Invalid handle", in other word function "WriteFile" in KeyboardProc procedure don`t get correct handle of earlier created file (as I think :)) ). But, strangest thing :)), when I look on this values on debugger, the value returned CreateFile such value sent as a handle of file in WriteFile!
