Stilllegung des Forums
Das Forum wurde am 05.06.2023 nach über 20 Jahren stillgelegt (weitere Informationen und ein kleiner Rückblick).
Registrierungen, Anmeldungen und Postings sind nicht mehr möglich. Öffentliche Inhalte sind weiterhin zugänglich.
Das Team von spieleprogrammierer.de bedankt sich bei der Community für die vielen schönen Jahre.
Wenn du eine deutschsprachige Spieleentwickler-Community suchst, schau doch mal im Discord und auf ZFX vorbei!
Werbeanzeige
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 |
#include <Wininet.h> #include <string> #include <vector> #include <tchar.h> #include <algorithm> void read_url(std::basic_string<TCHAR> const& url, std::vector<unsigned char>& dest) { dest.clear(); ::HINTERNET hInternet(::InternetOpen(TEXT("Microsoft Internet Explorer"), INTERNET_OPEN_TYPE_PRECONFIG, 0, 0, 0); if (hInternet == NULL) throw std::runtime_error("could not connect"); ::HINTERNET hURL(::InternetOpenUrl(hInternet, url.c_str(), 0, 0, INTERNET_FLAG_RELOAD, 0); if (hURL == NULL) { ::CloseHandle(hInternet); throw std::runtime_error("invalid url"); } unsigned char* tmp_arr = new unsigned char[128]; DWORD read_bytes(0L); while (::InternetReadFile(hURL, tmp_arr, 128, &read_bytes) != FALSE) { if (read_bytes == 0L) break; dest.resize(dest.size() + read_bytes); std::copy(tmp_arr, tmp_arr + read_bytes, &dest[dest.size() - read_bytes - 1]); } delete [] tmp_arr; ::CloseHandle(hURL); ::CloseHandle(hInternet); } |
C-/C++-Quelltext |
|
1 2 |
MessageBox(NULL,"Das stand in der Webseite",Inhalt,MB_OK); // angenommen Inhalt wäre d. Inhalt der Page als String (aba nich char)... xD |
C-/C++-Quelltext |
|
1 |
typedef basic_string<char> string; |
C-/C++-Quelltext |
|
1 |
::MessageBoxA(NULL, ReadUrl("http://www.google.de/").c_str(), "Inhalt von \"www.google.de\"", MB_OK | MB_ICONINFORMATION); |
Zitat
wie sollte man den denn umschreiben, dass den auch Microsoft Visual C++ aktzeptiert
C-/C++-Quelltext |
|
1 2 3 4 5 6 7 8 |
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, char* pcCommandLine, int iShowCommand) { std::string a = ReadUrl(argv[1]); tbWriteToLog(a.c_str()); } |
Zitat
da es sich bei g++ um einen c++-Compiler in Linux handelt.
Zitat von »"Deviloper"«
und jetzt überleg mal warum dann std::memset in Verbund mit C++ bäh ist
Werbeanzeige