Home > Software engineering >  Have a great god can help me have a look at how the code on the win10 run
Have a great god can help me have a look at how the code on the win10 run

Time:09-23

0400//# define _WIN32_WINNT global variables?
# define STRICT
# define WIN32_LEAN_AND_MEAN
# define WH_KEYBOARD_LL 13
# define WH_MOUSE_LL 14
#include
#include
#include
#include
#include //defines the CInternetSession MFC classes such as
#include
#include
# pragma comment (lib, "ws2_32")
//# pragma comment (would, "/subsystem: \ Windows " mainCRTStartup "/entry: " \ "")
using namespace std;

//file name global variable
Char filename [42]={0};

//the original data structure
Struct rawDATA
{
Int time;
String info;
int x;
Int y;
int key;
Double d;
} rdata [3].//this structure there are three members, stored in the form of an array variable called rdata

/*

* post function* parameters: the global variable hostName references the pathname postData
*/
Bool PostHttpPage (const STD: : string& The hostName, const STD: : string& The pathName, const STD: : string& PostData)//incoming is the function of reference rather than a function parameter itself
{
SJSZ CInternetSession session (" ");//create an Internet session

//session. SetOption (INTERNET_OPTION_CONNECT_TIMEOUT, 3000);//3 seconds of connection timeout
//session. SetOption (INTERNET_OPTION_SEND_TIMEOUT, 3000);//3 seconds to send timeout
//session. SetOption (INTERNET_OPTION_RECEIVE_TIMEOUT, 3000);//3 seconds to receive timeout
//session. SetOption (INTERNET_OPTION_DATA_SEND_TIMEOUT, 3000);//3 seconds to send timeout
//session. SetOption (INTERNET_OPTION_DATA_RECEIVE_TIMEOUT, 3000);//3 seconds to receive timeout
//session. SetOption (INTERNET_OPTION_CONNECT_RETRIES, 1);//1 retries

Try
{
INTERNET_PORT nPort=80;
DWORD dwRet=0;

/*
* c_str () function is to ensure that the string is compatible with C and C + + into the form of C pointer to the string
*/
CHttpConnection * pServer=session. GetHttpConnection (hostName. C_str (), nPort);
if (! PServer)
{
return false;
}
CHttpFile * pFile=pServer - & gt; OpenRequest (CHttpConnection: : HTTP_VERB_POST, pathName. C_str ());
if (! PFile)
{
return false;
}
Cstrings strHeaders="content-type: application/x - WWW - form - urlencoded";//request header

//send the request

PFile - & gt; The SendRequest (strHeaders, (LPVOID) postData c_str (), postData. The size ());
PFile - & gt; QueryInfoStatusCode (dwRet);


If (dwRet==HTTP_STATUS_OK)
{
Cstrings result, newline;

While (pFile - & gt; ReadString (newline))
{
//loop reads each line
The result +=newline;
}

//determine whether have reset command, _T into eight
If (result==_T (" reset "))
{
Rdata [2]. X=0;
Rdata [2]. The y=0;
Rdata [2]. The key=0;
Rdata [2]. D=0;
}

If (result==_T (" exit "))
{
exit(0);
}

STD: : cout & lt; & lt; Result & lt; & lt; STD: : endl;//display content return
//printf (" % s ", result);
}
The else
{
return false;
}
The delete pFile;
Delete the pServer;

}
The catch (CInternetException * pEx)
{
//catch errors from WinInet
TCHAR pszError [200].
PEx - & gt; GetErrorMessage (pszError, 200);

STD: : cout & lt; & lt; PszError & lt; & lt; STD: : endl;//display abnormal information

return false;
}
The session. The Close ();//close the session

return true;

}

//send data analysis analyze
Void postdata ()
{
//[0] this data, [1] the last data, [2]//combined data, [3] the average data

If (rdata [1]. X)
{
If (rdata [0]. Info=="lup")
Rdata [2]. X++;
Else if (rdata [0]. Info=="rup")
Rdata [2]. Y++;
Else if (rdata [0]. Info=="keyup")
Rdata [2]. Key++;
Else if (rdata [0]. Info=="syskeyup")
Rdata [2]. Key++;
Else if (rdata [0]. Info=="move")
Rdata [2]. D=rdata. [2] d + SQRT (pow ((rdata [0]. Y - rdata [1]. The y), 2) + pow ((rdata [0]. X-ray rdata [1]. The x), 2))/1000;
}

//end of the analysis, the data in the [1]
Rdata [1]=rdata [0];

}


//keyboard hook structure
Typedef struct tagKBDLLHOOKSTRUCT {
DWORD vkCode;
DWORD scanCode.
DWORD flags;
DWORD time;
DWORD dwExtraInfo;
} KBDLLHOOKSTRUCT, LPKBDLLHOOKSTRUCT FAR * and * PKBDLLHOOKSTRUCT;

//mouse hook structure
Typedef struct tagMSLLHOOKSTRUCT {
POINT pt;
DWORD mouseData;
DWORD flags;
DWORD time;
DWORD dwExtraInfo;
} MSLLHOOKSTRUCT, LPMSLLHOOKSTRUCT FAR * and * PMSLLHOOKSTRUCT;

DWORD g_main_tid=0;
HHOOK g_kb_hook=0;
HHOOK g_ms_hook=0;

BOOL CALLBACK con_handler (DWORD)
{
PostThreadMessage (g_main_tid WM_QUIT, 0, 0);
return TRUE;
};

//callback function keyboard
LRESULT a CALLBACK kb_proc (LPARAM int code, WPARAM w, l)
{
PKBDLLHOOKSTRUCT p=(PKBDLLHOOKSTRUCT) l;
Const char * info=NULL;
If (w==WM_KEYDOWN)
Info="keydn";
Else if (w==WM_KEYUP)
Info="keyup";
Else if (w==WM_SYSKEYDOWN)
Info="syskeydn";
Else if (w==WM_SYSKEYUP)
Info="syskeyup";

//write file
SYSTEMTIME sys.
GetLocalTime (& amp; Sys);

//ofstream outfile (filename, the ios: : app);
//outfile<& lt; (sys. WHour * 10000000 + sys. WMinute * 100000 + sys. WSecond * 1000 + sys. WMilliseconds)
nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related