Thread: action whilst downloading

  1. #1
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164

    action whilst downloading

    If I'm downloading a file via URLDownloadToFileA() how can I print something to the screen whilst it is downloading?

    If I have something after the function call, it obviously won't run until the function returns.
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

  2. #2
    SleepWalker tjohnsson's Avatar
    Join Date
    Apr 2004
    Posts
    70
    Quote Originally Posted by eth0
    If I'm downloading a file via URLDownloadToFileA() how can I print something to the screen whilst it is downloading?

    If I have something after the function call, it obviously won't run until the function returns.
    Use threads.
    -- Add Your Signature Here --

  3. #3
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    If you were thinking of displaying the progress of the download then this function dosen't provide anyway to do that.

  4. #4
    Registered User eth0's Avatar
    Join Date
    Dec 2003
    Posts
    164
    That was the plan.
    Can you tell me a function which would make life easier?

    The idea was to put a spinning bar in the command line to start with, and then maybe try replacing that with percentage figure later.
    Open source isn't a matter of life or death......
    .......its much more important than that!!


    SuSE Linux - GCC 3.4.2
    XP Pro - Visual Studio 2005 TS, MinGW 3.4.2

  5. #5
    Registered User
    Join Date
    Jan 2005
    Posts
    847
    Was the URLDownloadToFile function that you used like this?
    Code:
    HRESULT URLDownloadToFile(
        LPUNKNOWN pCaller,
        LPCSTR szURL,
        LPCSTR szFileName,
        DWORD dwReserved,
        LPBINDSTATUSCALLBACK lpfnCB
    );
    If thats the function you used then you can place your code to update the progress in a callback routine and pass it's pointer as the last paramater.

  6. #6
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    I've found URLDownloadToFile to be rather flaky. I've previously posted code that downloads a file to memory using wininet.

    As mentioned by Q1024, you can pass a pointer to an IBindStatusCallback COM interface as the last argument to URLDownloadToFile. This is a little more complicated to implement in C (sample here) than C++ (sample here - program 4).

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Retail Outlet Managment System - the 4th
    By Presidentofusa in forum C Programming
    Replies: 3
    Last Post: 11-10-2007, 10:44 PM
  2. need help on Calculator program in C
    By deathscyth129 in forum C Programming
    Replies: 8
    Last Post: 01-08-2005, 07:50 PM
  3. Directional Keys - Useing in Console
    By RoD in forum C++ Programming
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM
  4. FAQ: Directional Keys - Useing in Console
    By RoD in forum FAQ Board
    Replies: 38
    Last Post: 10-06-2002, 04:42 PM