URLDownloadToFile(NULL, "http://www.csdn.net/", "c:\\temp\\file.html", 0, NULL);

解决方案 »

  1.   

    bool SaveUrl(LPCTSTR url, LPCTSTR filename)
    {
    HINTERNET hNet = ::InternetOpen("Outlook",
    PRE_CONFIG_INTERNET_ACCESS,
    NULL,
    INTERNET_INVALID_PORT_NUMBER,
    0) ; HINTERNET hUrlFile = ::InternetOpenUrl(hNet,
    url,
    NULL,
    0,
    INTERNET_FLAG_RELOAD,
    0) ; char buffer[10*1024] ;
    DWORD dwBytesRead = 1;
    BOOL bRead=TRUE;
    CFile file;
    file.Open(filename,CFile::modeCreate|CFile::modeWrite);
    while(bRead&&dwBytesRead>0)
    {
    bRead = ::InternetReadFile(hUrlFile,
    buffer,
    sizeof(buffer),
    &dwBytesRead);
    if(dwBytesRead>0)
    file.Write(buffer,dwBytesRead);
    }
    ::InternetCloseHandle(hUrlFile) ;
    ::InternetCloseHandle(hNet) ;
    file.Close();
    AfxMessageBox("finished");
    return bRead;
    }
    void CC02021101Dlg::OnOK()
    {
    // TODO: Add extra validation here
    bool bret=SaveUrl("http://club.pchome.net/bbs2.php?topic=40&lanmuid=2","C:\\temp\\test.html");
    if(bret)
    AfxMessageBox("true");
    else
    AfxMessageBox("false");
    }
      

  2.   

    HINTERNET' : undeclared identifier ??
    要加什么头文件么??
      

  3.   

    Wininet.h   Wininet.lib
      

  4.   

    有谁知道,哪儿有例子代码??
    MY EMAIL: [email protected]
      

  5.   

    使用了 masterz 的代码,编译通过。运行后,很快就跳出“finished”;而且:
    下载zip文件时,得到的*.zip文件很小,只有1.05K; 
    下载html文件时,得到的*.html文件打开是无效的网页;谁可以指导我一下,谢谢!!
      

  6.   

    使用了 masterz 的代码,编译通过。运行后,很快就跳出“finished”;而且:
    下载zip文件时,得到的*.zip文件很小,只有1.05K; 
    下载html文件时,得到的*.html文件打开是无效的网页;谁可以指导我一下,谢谢!!