Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.17 KB | None | 0 0
  1. #include <iostream>
  2. #include <windows.h>
  3. #include <wininet.h>
  4.  
  5. #pragma comment(lib, "Wininet")
  6.  
  7. int main()
  8. {
  9.     HINTERNET hInternet = 0, hRequest; //Открываем новое подключение с юзер агентом "CheatPack"
  10.     hInternet = InternetOpenA("UserAgent", 0, 0, 0, 0);
  11.     if (!hInternet)
  12.     {
  13.         std::cout << "Error: can't open connect" << std::endl;
  14.         return -1;
  15.     }
  16.  
  17.     hRequest = InternetOpenUrlA(hInternet, "https://prime-hack.net/test_ip.php?test=Connected", 0, 0, 0, 0); //Обращаемся по адресу
  18.     if (!hRequest)
  19.     {
  20.         std::cout << "Error: can't send data" << std::endl;
  21.         return -2;
  22.     }
  23.  
  24.     if (!HttpSendRequestA(hRequest, NULL, 0, NULL, 0))
  25.     {
  26.         std::cout << "Error: can't get request" << std::endl;
  27.         return -3;
  28.     }
  29.  
  30.     //Читаем ответ от сервера
  31.     char szData[64];
  32.     memset(szData, 0, sizeof(szData));
  33.     DWORD dwBytesRead;
  34.     BOOL bRead = InternetReadFile(hRequest, szData, sizeof(szData) - 1, &dwBytesRead);
  35.     if (dwBytesRead < 64)
  36.         szData[dwBytesRead] = 0;
  37.  
  38.     if (!InternetCloseHandle(hInternet))
  39.     {
  40.         std::cout <<  "Error: can't close connect" << std::endl;
  41.         return -4;
  42.     }
  43.  
  44.     std::cout << std::endl << szData << std::endl << std::endl;
  45.     return 0;
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement