downloading a web page

I've been looking around the web for information on downloading a web page from a C++ or Visual C++ program. I've done it before in Perl and VB, but I can't find any information on doing it in C++.

Any help is appreciated!

-- Patrick Cupka

Comments

  • : I've been looking around the web for information on downloading a web page from a C++ or Visual C++ program. I've done it before in Perl and VB, but I can't find any information on doing it in C++.
    :
    : Any help is appreciated!
    :
    : -- Patrick Cupka
    :

    You have done it through Microsoft Internet Transfer Control
    in VB, isn't it? You can also use Microsoft Internet Transfer
    Control in VC++. Go to projects - add to projects - components
    and control.
  • : You have done it through Microsoft Internet Transfer Control
    : in VB, isn't it? You can also use Microsoft Internet Transfer
    : Control in VC++. Go to projects - add to projects - components
    : and control.

    No, I used the Winsock Control ... I'll try that ITC component, thanks.
  • : : You have done it through Microsoft Internet Transfer Control
    : : in VB, isn't it? You can also use Microsoft Internet Transfer
    : : Control in VC++. Go to projects - add to projects - components
    : : and control.
    :
    : No, I used the Winsock Control ... I'll try that ITC component, thanks.
    :

    You could also use CInternetSession, or InternetOpen..
  • : : : You have done it through Microsoft Internet Transfer Control
    : : : in VB, isn't it? You can also use Microsoft Internet Transfer
    : : : Control in VC++. Go to projects - add to projects - components
    : : : and control.
    : :
    : : No, I used the Winsock Control ... I'll try that ITC component, thanks.
    : :
    :
    : You could also use CInternetSession, or InternetOpen..
    :

    Hi, this code download a File from a web:

    -----------------------------------------------------------------

    bool InetStartup()
    {
    g_hInternet = InternetOpen( INTERNET_OPEN_TYPE_PRECONFIG,
    NULL,
    NULL,
    NULL,
    0 );

    HINTERNET hSession;
    DWORD dwContext = 0;

    hSession = InternetOpenUrl( g_hInternet,
    _T("http://www.stratos-ad.com/gfx/home_top_01.gif"),
    NULL,
    0,
    0,
    dwContext );

    char pBufferData[1024];
    DWORD dwBytesRead;
    DWORD dwBytesWrite;
    HANDLE hFile = CreateFile( _T("Dibujo.gif"),
    GENERIC_READ | GENERIC_WRITE,
    0,
    NULL,
    CREATE_NEW,
    FILE_ATTRIBUTE_NORMAL,
    NULL );

    while( InternetReadFile( hSession,
    pBufferData,
    1023,
    &dwBytesRead ) )
    {
    pBufferData[dwBytesRead] = 0;

    OutputDebugString( pBufferData );
    OutputDebugString( _T("
    ") );

    if( dwBytesRead == 0 ) break;

    WriteFile( hFile, pBufferData, dwBytesRead, &dwBytesWrite, NULL );
    }

    CloseHandle( hFile );

    IWebBrowser2 objWebBrowser;

    return true;
    }

    bool InetStop()
    {
    InternetCloseHandle( g_hInternet );
    return true;
    }

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories