How to read IE settings with WinInet?

Posted on 2009-12-18
Last Modified: 2013-11-23
I want to download a large file from a server but that file is created on the fly (when the request arrives)  and so it could happen that there are pauses while downloading. The file consists of several parts and they take sometime to assemble. When the download of the first part is faster than assembling the second part there will be a delay.

Downloading with WinInet calls leads to problems because when the delay is too long InternetReadfile() times out. I don't know how to increase this timeout period of the InternetReadFile call.

I submitted already another question about that problem but that is still open. It does work fine when I download the file with Indy and set ReadTimeout accordingly. Since I need to use the Internet Explorer settings (therefore I tried downloading it with WinInet) my workaround is to read the IE settings with WinInet and then configure the Indy class accordingly.

Does anyone know which settings I need to use, how to read them with WinInet and which properties need to be configured in TIdHttp?

Question by:dirkil2
    LVL 3

    Accepted Solution

    The following function will return True or False to indicate whether IE is using a proxy,
    the Proxy Name & Port (for http) is also returned in the var's HostName & HostPort.

    I use this function to configure my proxy settings for the various components I use from "Internet Component Suite" (
    function GetIEProxySettings(var HostName: string; var HostPort: string): Boolean;
      ProxyInfo   : PInternetProxyInfo;
      Len         : LongWord;
      i           : Integer;
      sProxyResult: AnsiString;
      Result := False;
      Len := 4096;
      GetMem(ProxyInfo, Len);
        if InternetQueryOption(nil, INTERNET_OPTION_PROXY, ProxyInfo, Len) then
          Result := ProxyInfo^.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
          if Result then
            sProxyResult := AnsiString(ProxyInfo^.lpszProxy);
            i := Pos('http=', sProxyResult) + Length('http=') - 1;
            if (i > 0) then
              Delete(sProxyResult, 1, i);
              if Length(sProxyResult) > 0 then
                i := Pos(':', sProxyResult) - 1;
                if (i > 0) then
                  HostName := Copy(sProxyResult, 1, i);
                  Delete(sProxyResult, 1, i+1);
                  i := Pos(';', sProxyResult) - 1;
                  if (i <= 0) then
                    i := Pos(' ', sProxyResult) - 1;
                  if (i > 0) then
                    HostPort := Copy(sProxyResult, 1, i);

    Open in new window


    Author Closing Comment

    Thank you very much.

    Featured Post

    How to run any project with ease

    Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
    - Combine task lists, docs, spreadsheets, and chat in one
    - View and edit from mobile/offline
    - Cut down on emails

    Join & Write a Comment

    Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
    Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

    734 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    24 Experts available now in Live!

    Get 1:1 Help Now