Thread: InternetQueryDataAvailable problem

  1. #1
    Registered User
    Join Date
    Sep 2004
    Posts
    124

    InternetQueryDataAvailable problem

    Hi all,

    The InternetQueryDataAvailable function seems to not return what I expect. I would expect it to return the length of the file you are pointing to by hUrlFile, thus if it's 12345 bytes long then I'd expect to see this function return 12345.

    It seems to return far less - as though it's loading up one buffer of data and returning the length of that instead.

    Cut-down code fragment is as follows:

    Code:
    HINTERNET hNet;
    HINTERNET hUrlFile;
    int bytes;
    LPDWORD dlsize;
    ...
    hNet = InternetOpen(is_programtitle, PRE_CONFIG_INTERNET_ACCESS, NULL, NULL, 0);
    ...
    hUrlFile = InternetOpenUrl(hNet, "http://www.angmail.fsnet.co.uk/angoid/filename.txt", NULL, 0, INTERNET_FLAG_RESYNCHRONIZE|INTERNET_FLAG_RELOAD, 0);
    ...
    bytes = InternetQueryDataAvailable(hUrlFile, &dlsize, 0, 0);
    ...
    ...
    The value returned in dlsize does not appear to be an accurate representation of the file size being opened on the Internet.

    Also, does it make any difference as to whether you are accessing a simple txt file or a page pf PHP that just sends plain text back?

    TIA!

  2. #2
    Registered User Codeplug's Avatar
    Join Date
    Mar 2003
    Posts
    4,981
    I've never used those API's, but what you describe seems consistent with the documentation.

    gg

  3. #3
    Registered User
    Join Date
    Sep 2004
    Posts
    124
    (BTW sorry about the ugly horizontal scrollbar you might see as a result of the long lines of code.)

    In that case, is there a function that will return the size of the file you want to download?

    I want to have one of those progress meters which shows the amount of file downloaded as it downloads.

    Anyone?

  4. #4
    Yes, my avatar is stolen anonytmouse's Avatar
    Join Date
    Dec 2002
    Posts
    2,544
    For web files, you could try HttpQueryInfo() with HTTP_QUERY_CONTENT_LENGTH.

    For ftp files, you could try FtpGetFileSize().

    However, size information will not be available on all files, especially dynamically generated pages.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Need help understanding a problem
    By dnguyen1022 in forum C++ Programming
    Replies: 2
    Last Post: 04-29-2009, 04:21 PM
  2. Memory problem with Borland C 3.1
    By AZ1699 in forum C Programming
    Replies: 16
    Last Post: 11-16-2007, 11:22 AM
  3. Someone having same problem with Code Block?
    By ofayto in forum C++ Programming
    Replies: 1
    Last Post: 07-12-2007, 08:38 AM
  4. A question related to strcmp
    By meili100 in forum C++ Programming
    Replies: 6
    Last Post: 07-07-2007, 02:51 PM
  5. WS_POPUP, continuation of old problem
    By blurrymadness in forum Windows Programming
    Replies: 1
    Last Post: 04-20-2007, 06:54 PM