windows - C ++ Win32 Wininet forårsager Lags eller My Code?

Indlæg af Hanne Mølgaard Plasc

Problem



Jeg lavede et program ved hjælp af Code :: Blocks og compiled det med GNU GCC Compiler. Når jeg klikker på en knap virkelig hurtigt, får jeg et rigtig dårligt lag, jeg ved ikke om det er på grund af min kode eller hvis det er fordi jeg bruger Cases for hver knap. Af min dårlige måde at bruge strengstrømme og streng for at gøre min strengkoncentration im stadig ny til dette, men det virker, hvis nogen ved det, vil det hjælpe meget tak. det


case WM\_COMMAND:
        switch(LOWORD(wParam))
        {
            /*
             * TODO: Add more control ID's, when needed.
             */
            case Create:
            {
                GetDlgItemText(hwndDlg, GuildN, Readuni, sizeof(Readuni));
                GetDlgItemText(hwndDlg, PWN, Readpw, sizeof(Readpw));
                GetDlgItemText(hwndDlg, Namen, Readnamec, sizeof(Readnamec));
                GetDlgItemText(hwndDlg, souln, Readsoulc, sizeof(Readsoulc));
                std::stringstream ss;
                ss << "uniform=" << Readuni << "&pw=" << Readpw;
                std::string sss = ss.str();
                char frmdata[1000] ;
                for(int i=0;i<1000;i++)
                frmdata[i]=sss[i];
                std::stringstream ssurl;
                ssurl << "/cgi-bin/myCGI/sr-guilds.cgi/WOS/create/0/" << Readsoulc << "." << Readnamec << "/31321/00000000";
                std::string url = ssurl.str();
                //std::string url("/cgi-bin/myCGI/sr-guilds.cgi/WOS/create/0/00000001.Samsyn/31321/00000000");
                hSession = InternetOpen("wosPost",INTERNET\_OPEN\_TYPE\_PRECONFIG, NULL, NULL, 0);
                hConnect = InternetConnect(hSession, "207.57.118.86",INTERNET\_DEFAULT\_HTTP\_PORT, NULL, NULL, INTERNET\_SERVICE\_HTTP, 0, 1);
                hRequest = HttpOpenRequest(hConnect, "POST", url.c\_str(), NULL, NULL, NULL, 0, 1);
                HttpSendRequest(hRequest, hdrs, strlen(hdrs), frmdata, strlen(frmdata));
                InternetCloseHandle(hSession);
                InternetCloseHandle(hConnect);
                InternetCloseHandle(hRequest);
                r

eturn TRUE;
                }
case joinr:
            {
                    GetDlgItemText(hwndDlg, guildj, Readguildj, sizeof(Readguildj));
                    GetDlgItemText(hwndDlg, namej, Readnamej, sizeof(Readnamej));
                    std::string fill = "00000";
                    int randomValue = rand() \%899 + 100;
                    std::stringstream ss;
                    ss << "desc=Level 100 Emperor (Sword-User) age 80:23 (Evergreen) (PKer)&stat=Kills:4085, PKs:2503, Deaths:15, PKed:2830, Rating: 800&name=" << fill << randomValue << "." << Readnamej;
                    std::string sss = ss.str();
                    char frmdata[1500] ;
                    for(int i=0;i<1500;i++)
                    frmdata[i]=sss[i];
                    std::stringstream ssurl;
                    ssurl << "/cgi-bin/myCGI/sr-guilds.cgi/WOS/petition/" << Readguildj << "/" << Readnamej << "." << fill << randomValue << "/31321/00000000";
                    std::string url = ssurl.str();
                    //std::string url("/cgi-bin/myCGI/sr-guilds.cgi/WOS/create/0/00000001.Samsyn/31321/00000000");
                    hSession = InternetOpen("wosPost",INTERNET\_OPEN\_TYPE\_PRECONFIG, NULL, NULL, 0);
                    hConnect = InternetConnect(hSession, "207.57.118.86",INTERNET\_DEFAULT\_HTTP\_PORT, NULL, NULL, INTERNET\_SERVICE\_HTTP, 0, 1);
                    hRequest = HttpOpenRequest(hConnect, "POST", url.c\_str(), NULL, NULL, NULL, 0, 1);
                    HttpSendRequest(hRequest, hdrs, strlen(hdrs), frmdata, strlen(frmdata));
                    InternetCloseHandle(hSession);
                    InternetCloseHandle(hConnect);
                    InternetCloseHandle(hRequest);
                    return TRUE;
                    }


Her er stort set den samme kode kodet med QT, der ikke lagrer.


void MainWindow::on\_Join2\_clicked()
{
    QString Fill = "00000";
    int randomValue = rand() \%899 + 100;
    QString inttostr;
    inttostr.append(QString("\%1").arg(randomValue));
    QString guildslot = ui->GuildJ->text();
    QString NamexJ = ui->NameJ->text();
    QNetworkRequest request(QUrl("http://synthetic-reality.com/cgi-bin/myCGI/sr-guilds.cgi/WOS/petition/" + guildslot + "/" + Fill + inttostr + "." + NamexJ + "/31321/00000000"));
    request.setRawHeader("User-Agent", "wosPost");
    request.setHeader(QNetworkRequest::ContentTypeHeader, "application/x-www-form-urlencoded; charset=UTF-8");
    QByteArray content = "";
    content += "desc=Level 100 Emperor (Sword-User) age 80:23 (Evergreen) (PKer)&";
    content += "stat=Kills:4085, PKs:2503, Deaths:15, PKed:2830, Rating: 800&";
    content += "name=" + Fill + inttostr + "." + NamexJ;
    QNetworkAccessManager *networkManager = new QNetworkAccessManager(this);
    networkManager->post(QNetworkRequest(request), content);

}

Bedste reference