+ -
当前位置:首页 → 问答吧 → 我写了一个MFC获取网页源代码的程序,为什么报错?

我写了一个MFC获取网页源代码的程序,为什么报错?

时间:2011-12-04

来源:互联网

这个是响应“读取”按钮的代码,上面那个EDIT框是用来输入URL的,下面那个EDIT框是用来输出网页源码的
C/C++ code

void CGetHtmlDlg::OnREAD()
{

UpdateData(true);
CInternetSession httpSession;
CInternetFile* htmlFile = (CInternetFile*) httpSession.OpenURL(m_url);
CString content;
while (htmlFile->ReadString(content))
{
   m_html += content + " ";
}
htmlFile->Close();
httpSession.Close();
UpdateData(false);

}


下面这个是运行时弹出的错误,怎么解决啊?

作者: tztztz   发布时间: 2011-12-04

帮楼主顶下!

作者: danxiaodeshitou   发布时间: 2011-12-04

C/C++ code

    UpdateData(TRUE);
    try
    {
        CInternetSession httpSession(_T("session"));
        CInternetFile* htmlFile = (CInternetFile*) httpSession.OpenURL(m_url);
        CString content;
        while (htmlFile->ReadString(content))
        {
            m_html += content + " ";
        }
        htmlFile->Close();
        httpSession.Close();
    }
    catch (CInternetException* e)
    {
        e->ReportError();
        e->Delete();
    }

    UpdateData(FALSE);

作者: VisualEleven   发布时间: 2011-12-04

打开IIS管理器(可在控制面板找到)
打开[本地计算机]
 展开Web服务扩展.
将 Active Server Pages 设置为允许

作者: fight_in_dl   发布时间: 2011-12-04

引用 2 楼 visualeleven 的回复:

C/C++ code

UpdateData(TRUE);
try
{
CInternetSession httpSession(_T("session"));
CInternetFile* htmlFile = (CInternetFile*) httpSession.OpenURL(m_url);
CString co……

试过了,还是弹出一样的错误。。。
我用的VC6

作者: tztztz   发布时间: 2011-12-04