这是微软帮助中 wininet 提交表单代码
   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());
如何获取返回的网页源码信息 求高手

解决方案 »

  1.   

    用pFile-〉read可以获得html源码
      

  2.   

    CString strHeaders =_T("Content-Type: application/x-www-form-urlencoded");
    CString strFormData = _T("username=hello&normModPsp=hello");
    CInternetSession session;
    CHttpConnection* pConnection = session.GetHttpConnection("passport.baidu.com");
    CHttpFile* pFile = pConnection->OpenRequest(CHttpConnection::HTTP_VERB_POST,_T("passport.baidu.com/?login"));
    BOOL result = pFile->SendRequest(strHeaders,(LPVOID)(LPCTSTR)strFormData, strFormData.GetLength());
    我套用百度的参数 返回的页面源码是 访问出错,错误的页面 请问这个是什么原因 谢谢了,如果能帮助我 马上就节分了 谢谢
      

  3.   

    访问出错说明Post失败了
    看你的应用建议你用OpenURL比方便
      

  4.   

    参考之~~

    VC POST表单模拟登录新浪邮箱
    利用WinInet查询考生信息[更新时间: 2011-02-25] VC驿站助手v1.0
      

  5.   


    一个网站如果设置了request源 就是防止外部提交 wininet能实现吗还