zoukankan      html  css  js  c++  java
  • VC提交表单

    //computer.jsp功能为根据三角形三边求面积
    void PostForm()
    {
        CInternetSession  session("My Session");         
        CHttpConnection *pServer = NULL;         
        CHttpFile *pFile = NULL;         
        CString ServerName = "127.0.0.1";         
        INTERNET_PORT nPort = 8080;         
        DWORD retcode;         
        char  outBuff[] = "sideA=3&sideB=4&sideC=5";//三角形三边
        try         
        {         
            pServer = session.GetHttpConnection(ServerName,nPort);         
            pFile = pServer->OpenRequest(CHttpConnection::HTTP_VERB_POST,"computer.jsp",NULL,1,NULL,NULL,INTERNET_FLAG_EXISTING_CONNECT);         
            pFile->AddRequestHeaders("Content-Type:application/x-www-form-urlencoded");         
            pFile->AddRequestHeaders("Accept:*/*");  
            pFile->SendRequest(NULL,0,outBuff,strlen(outBuff)+1);         
            pFile->QueryInfoStatusCode(retcode);         
             
            DWORD dwlen=pFile->GetLength();         
            char  *buf = new char[dwlen];         
            DWORD  dwread=pFile->Read(buf,1024);
            printf("%s
    ", buf);
            delete []buf;   
        }         
        catch (CInternetException e)
        {
            AfxMessageBox("Error Occur!");
        }    
        delete pFile;         
        delete pServer;         
        session.Close();         
         
    }


  • 相关阅读:
    线程高并发
    29(套接字)就是网络编程
    28线程
    27 枚举
    26静态导入和可变参数
    25JDK新特性
    25断言 assert关键字
    24单元测试 junit
    炫酷CSS
    PHP 汉字转拼音类
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13318429.html
Copyright © 2011-2022 走看看