CLR ile Download string

Status
Not open for further replies.

xxsynape0707

Member
Joined
Oct 3, 2020
Topics
1
Messages
4
Reaction score
0
RC Point
0
Bildiğiniz gibi console app'de şu kod ile uzaktan bir pastebin raw olsa bile veri çekebiliyor

C++:
#include <Windows.h>
#include <string>
#include <iostream>
#include <Wininet.h>
#include <string>
#pragma comment(lib, "wininet.lib")

using namespace std;

string replaceAll(string subject, const string& search,
    const string& replace) {
    size_t pos = 0;
    while ((pos = subject.find(search, pos)) != string::npos) {
        subject.replace(pos, search.length(), replace);
        pos += replace.length();
    }
    return subject;
}

string DownloadString(string URL) {
    HINTERNET interwebs = InternetOpenA("Mozilla/5.0", INTERNET_OPEN_TYPE_DIRECT, NULL, NULL, NULL);
    HINTERNET urlFile;
    string rtn;
    if (interwebs) {
        urlFile = InternetOpenUrlA(interwebs, URL.c_str(), NULL, NULL, NULL, NULL);
        if (urlFile) {
            char buffer[2000];
            DWORD bytesRead;
            do {
                InternetReadFile(urlFile, buffer, 2000, &bytesRead);
                rtn.append(buffer, bytesRead);
                memset(buffer, 0, 2000);
            } while (bytesRead);
            InternetCloseHandle(interwebs);
            InternetCloseHandle(urlFile);
            string p = replaceAll(rtn, "|n", "\r\n");
            return p;
        }
    }
    InternetCloseHandle(interwebs);
    string p = replaceAll(rtn, "|n", "\r\n");
    return p;
}

int main() {

    setlocale(LC_ALL, "Turkish");
    string lol = DownloadString("https://hastebin.com/raw/otuponelaq");
    string gir;
    cin >> gir;
    string gir2;
    cin >> gir2;


    if (gir == gir2)
    {
        cout << " Giriş başarılı " << endl;
    }
    else
    {
        cout << " Giriş başarısız " << endl;
    }
    return 0;
}

Bu tarz bi stringi uzaktan veri alabilcek bir CLR tarzı lazım kodu baya bir araştırdım bulamadım? CLR'den demek istediğim birazcık daha VB.net'e yakın C++ form kütüphanesidir
 
Status
Not open for further replies.
Top