1.将ping的结果写入文件,
  如程序中运行:ping xxx.xxx.xxx.xxx >c:temp.txt  ,然后打开读取该文件获取返回结果。2.如何得到主机IP地址:
//获得局域网IP地址
void CIpDlg::OnIpbtn() 
{
// TODO: Add your control notification handler code here
       WORD wVersionRequested;
       WSADATA wsaData;      //Start up WinSock
       wVersionRequested = MAKEWORD(1, 1);
       WSAStartup(wVersionRequested, &wsaData);
        hostent *p;
        char s[128];
        char *p2;        //获得计算机名字
        gethostname(s, 128);
        p = gethostbyname(s);
     
        //获得IP地址
        p2 = inet_ntoa(*((in_addr *)p->h_addr));
        m_LocalIp =  CString(p2);        WSACleanup();
        UpdateData(FALSE);
}3.向服务器发送post请求

解决方案 »

  1.   

    2.
    你能说得具体点吗?想怎么修改
    3.
    HOWTO: Simulate a Form POST Request Using WinInet (Q165298)--------------------------------------------------------------------------------
    The information in this article applies to:
    The Microsoft Foundation Classes (MFC), included with: 
    Microsoft Visual C++, 32-bit Enterprise Edition, version 4.2 
    Microsoft Visual C++, 32-bit Professional Edition, version 4.2 
    Microsoft Visual C++, 32-bit Enterprise Edition, version 5.0 
    Microsoft Visual C++, 32-bit Professional Edition, version 5.0 
    Microsoft Internet Explorer (Programming) versions 4.0 , 4.01 
    --------------------------------------------------------------------------------
    SUMMARY
    To properly simulate a Form submission using WinInet, you need to send a header that indicates the proper Content-Type. For Forms, the proper Content-Type header is: Content-Type: application/x-www-form-urlencodedMORE INFORMATION
    In many cases, the server does not respond appropriately if a Content-Type is not specified. For example, the Active Server Pages component of IIS 3.0 actually checks this header specifically for 'application/x-www-form- urlencoded' before adding form variables to the "Request.Form" object. This MIME/Content-Type indicates that the data of the request is a list of URL- encoded form variables. URL-encoding means that space character (ASCII 32) is encoded as '+', special character such '!' encoded in hexadecemal form as '%21'. Here is a snippet of code that uses the MFC WinInet classes to simulate a Form POST request:    CString strHeaders =
          _T("Content-Type: application/x-www-form-urlencoded");
       // URL-encoded form variables -
       // name = "John Doe", userid = "hithere", other = "P&Q"
       CString strFormData = _T("name=John+Doe&userid=hithere&other=P%26Q");   CInternetSession session;
       CHttpConnection* pConnection =
          session.GetHttpConnection(_T("ServerNameHere"));
       CHttpFile* pFile =
          pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,
                                  _T("FormActionHere"));
       BOOL result = pFile->SendRequest(strHeaders,
          (LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
    Without MFC, the same code translates to straight SDK calls as follows: 
       static TCHAR hdrs[] =
          _T("Content-Type: application/x-www-form-urlencoded");
       static TCHAR frmdata[] =
          _T("name=John+Doe&userid=hithere&other=P%26Q");
       statuc TCHAR accept[] =
          _T("Accept: */*");   // for clarity, error-checking has been removed
       HINTERNET hSession = InternetOpen("MyAgent",
          INTERNET_OPEN_TYPE_PRECONFIG, NULL, NULL, 0);
       HINTERNET hConnect = InternetConnect(hSession, _T("ServerNameHere"),
          INTERNET_DEFAULT_HTTP_PORT, NULL, NULL, INTERNET_SERVICE_HTTP, 0, 1);
       HINTERNET hRequest = HttpOpenRequest(hConnect, "POST",
          _T("FormActionHere"), NULL, NULL, accept, 0, 1);
       HttpSendRequest(hRequest, hdrs, strlen(hdrs), frmdata, strlen(frmdata));
       // close any valid internet-handlesREFERENCES
    For more information on URL-encoding and the format of a Form POST request, see section 8.2 in RFC 1866. 
      

  2.   

    1.
    在程序中运行ping命令,如何得到其返回值(至少要知道ping通了没有)?
    (35')2.
    如何得到主机IP地址?如何修改?
    (15')3.
    如何在程序中向另一个地址提交一个请求,模拟网页中提交一个form那样?
    (30')4.
    怎么修改Internet选项,更改其局域网设置->代理服务器的选项就可以了。
    (20')×××××××××××××××××××××××××××××××××
    发文者总结一下:
    1.已经解决(似乎简单了点,呵呵,水平有限,不知道问题有多复杂)2.那段程序不能运行,要包含什么文件吗?另,那段代码是不是只能获得主机IP地址而不能修改?如果想修改怎么办?3.水平比较烂,看不懂,但分数会给的。4.没有人知道吗?我想在程序中修改,退出程序的时候还要修改回来,怎么做?
      

  3.   

    用GDI+
    ================================================================CSDN 论坛助手 Ver 1.0 B0402提供下载。 改进了很多,功能完备!★  浏览帖子速度极快![建议系统使用ie5.5以上]。 ★  多种帖子实现界面。 
    ★  保存帖子到本地[html格式]★  监视您关注帖子的回复更新。
    ★  可以直接发贴、回复帖子★  采用XML接口,可以一次性显示4页帖子,同时支持自定义每次显示帖子数量。可以浏览历史记录! 
    ★  支持在线检测程序升级情况,可及时获得程序更新的信息。★★ 签名  ●  
         可以在您的每个帖子的后面自动加上一个自己设计的签名哟。Http://www.ChinaOK.net/csdn/csdn.zip
    Http://www.ChinaOK.net/csdn/csdn.rar
    Http://www.ChinaOK.net/csdn/csdn.exe    [自解压]