Advertisement
Thunder-Menu

VectorString_GithubRaw c++

Apr 5th, 2023 (edited)
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.39 KB | Source Code | 0 0
  1. #include <Windows.h>
  2. #include <wininet.h>
  3. #include <iostream>
  4. #include <vector>
  5.  
  6. #pragma comment(lib, "wininet.lib")
  7. vector<string> RAWTRANSLATION;
  8.  
  9. char* langage::rawchar;
  10. int langage::rawrequest() {
  11. RAWTRANSLATION.clear();
  12. HINTERNET hInternet = InternetOpenW(L"WinINet Example", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, 0);
  13. if (!hInternet) {
  14. cerr << "Failed to open internet handle" << endl;
  15. return 1;
  16. }
  17.  
  18. HINTERNET hConnection = InternetConnectW(hInternet, L"raw.githubusercontent.com", INTERNET_DEFAULT_HTTPS_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 0);
  19. if (!hConnection) {
  20. cerr << "Failed to connect to internet" << endl;
  21. InternetCloseHandle(hInternet);
  22. return 1;
  23. }
  24. HINTERNET hRequest = nullptr;
  25. if (rawchar == "VF")
  26. {
  27. hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/VF.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
  28. if (!hRequest) {
  29. cerr << "Failed to open HTTP request" << endl;
  30. InternetCloseHandle(hConnection);
  31. InternetCloseHandle(hInternet);
  32. return 1;
  33. }
  34. }
  35. if (rawchar == "CHINESES")
  36. {
  37. hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/CHINESES.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
  38. if (!hRequest) {
  39. cerr << "Failed to open HTTP request" << endl;
  40. InternetCloseHandle(hConnection);
  41. InternetCloseHandle(hInternet);
  42. return 1;
  43. }
  44. }
  45. if (rawchar == "RUSSE")
  46. {
  47. hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/RUSSE.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
  48. if (!hRequest) {
  49. cerr << "Failed to open HTTP request" << endl;
  50. InternetCloseHandle(hConnection);
  51. InternetCloseHandle(hInternet);
  52. return 1;
  53. }
  54. }
  55. if (rawchar == "SPANISH")
  56. {
  57. hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/SPANISH.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
  58. if (!hRequest) {
  59. cerr << "Failed to open HTTP request" << endl;
  60. InternetCloseHandle(hConnection);
  61. InternetCloseHandle(hInternet);
  62. return 1;
  63. }
  64. }
  65. if (rawchar == "UKRAINIEN")
  66. {
  67. hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/UKRAINIEN.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
  68. if (!hRequest) {
  69. cerr << "Failed to open HTTP request" << endl;
  70. InternetCloseHandle(hConnection);
  71. InternetCloseHandle(hInternet);
  72. return 1;
  73. }
  74. }
  75. if (rawchar == "VO")
  76. {
  77. hRequest = HttpOpenRequestW(hConnection, L"GET", L"/3xploitch3ats/Thunder-Menu/langage/VO.langage", NULL, NULL, NULL, INTERNET_FLAG_SECURE | INTERNET_FLAG_RELOAD, 0);
  78. if (!hRequest) {
  79. cerr << "Failed to open HTTP request" << endl;
  80. InternetCloseHandle(hConnection);
  81. InternetCloseHandle(hInternet);
  82. return 1;
  83. }
  84. }
  85.  
  86. if (!HttpSendRequestW(hRequest, NULL, 0, NULL, 0)) {
  87. cerr << "Failed to send HTTP request" << endl;
  88. InternetCloseHandle(hRequest);
  89. InternetCloseHandle(hConnection);
  90. InternetCloseHandle(hInternet);
  91. return 1;
  92. }
  93.  
  94. const int BUFFER_SIZE = 1024;
  95. char buffer[BUFFER_SIZE];
  96. DWORD bytesRead = 0;
  97. string currentLine = "";
  98.  
  99. while (InternetReadFile(hRequest, buffer, BUFFER_SIZE, &bytesRead) && bytesRead != 0) {
  100. for (int i = 0; i < bytesRead; i++) {
  101. if (buffer[i] == '\n') {
  102. // Add current line to vector
  103. RAWTRANSLATION.push_back(currentLine);
  104. currentLine = "";
  105. }
  106. else {
  107. currentLine += buffer[i];
  108. }
  109. }
  110. }
  111.  
  112. // Add last line to vector (if there is one)
  113. if (!currentLine.empty()) {
  114. RAWTRANSLATION.push_back(currentLine);
  115. }
  116.  
  117. InternetCloseHandle(hRequest);
  118. InternetCloseHandle(hConnection);
  119. InternetCloseHandle(hInternet);
  120.  
  121. return 0;
  122. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement