void SendHardverInfo(){
DWORD VolumeSerialNumber;
if (GetVolumeInformation("C:\\", 0, 0, &VolumeSerialNumber, 0, 0, 0, 0) == 0)
{
return;
}
UUID uuid;
UuidCreateSequential(&uuid);
SYSTEM_INFO SystemInfo;
GetSystemInfo(&SystemInfo);
DWORD ComputerHardwareId1 = VolumeSerialNumber ^ 0x12B586FE;
DWORD ComputerHardwareId2 = *(DWORD*)(&uuid.Data4[2]) ^ 0x5D78A569;
DWORD ComputerHardwareId3 = ((*(WORD*)(&uuid.Data4[6]) & 0xFFFF) | (SystemInfo.wProcessorArchitecture << 16)) ^ 0xF45BC123;
DWORD ComputerHardwareId4 = ((SystemInfo.wProcessorLevel & 0xFFFF) | (SystemInfo.wProcessorRevision << 16)) ^ 0xB542D8E1;
//SENDSERVER
WSADATA wsaData;
if (WSAStartup(MAKEWORD(2, 2), &wsaData) != 0) {
return;
}
SOCKET Socket = socket(AF_INET, SOCK_STREAM, IPPROTO_TCP);
struct hostent *host;
host = gethostbyname("www.mysite.com");
SOCKADDR_IN SockAddr;
SockAddr.sin_port = htons(80);
SockAddr.sin_family = AF_INET;
SockAddr.sin_addr.s_addr = *((unsigned long*)host->h_addr);
if (connect(Socket, (SOCKADDR*)(&SockAddr), sizeof(SockAddr)) != 0){
return;
}
char Text[256];
ZeroMemory(Text, sizeof(Text));
sprintf(Text, "%08X-%08X-%08X-%08X", ComputerHardwareId1, ComputerHardwareId2, ComputerHardwareId3, ComputerHardwareId4);
char link[500];
strcat(link, "GET /api/hardverinfo.php?hardverinfo=");
strcat(link, Text);
strcat(link, " HTTP/1.1\r\nHost: www.mysite.com\r\nConnection: close\r\n\r\n");
send(Socket, link, strlen(link), 0);
char buffer[10000];
int nDataLength;
while ((nDataLength = recv(Socket, buffer, 10000, 0)) > 0){
int i = 0;
while (buffer[i] >= 32 || buffer[i] == '\n' || buffer[i] == '\r') {
i += 1;
}
}
closesocket(Socket);
WSACleanup();
printf(link);
return;
//ENDSEND
}
嗨,我有这个代码,它的工作和良好。但是在我向网站发送GET请求后,我想要处理答案,所以例如在完成get之后网站给出了回复确定,我想在我的应用程序中处理这个问题,我该怎么做?
答案 0 :(得分:1)
将您的GET请求标头更改为此
" HTTP/1.1\r\nHost: www.mysite.com\r\nContent-type: application/x-www-form-urlencoded\r\n\r\n";
而不是最后的标题部分。这应该强制你的php服务器以你的应用程序可读的格式进行响应。