Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

How to read IE settings with WinInet?

Posted on 2009-12-18
2
Medium Priority
?
338 Views
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?

Regards,
Dirk.
0
Comment
Question by:dirkil2
2 Comments
 
LVL 3

Accepted Solution

by:
sYk0 earned 2000 total points
ID: 26305794
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" (www.overbyte.be)
function GetIEProxySettings(var HostName: string; var HostPort: string): Boolean;
var
  ProxyInfo   : PInternetProxyInfo;
  Len         : LongWord;
  i           : Integer;
  sProxyResult: AnsiString;
begin
  Result := False;
  Len := 4096;
  GetMem(ProxyInfo, Len);
  try
    if InternetQueryOption(nil, INTERNET_OPTION_PROXY, ProxyInfo, Len) then
    begin
      Result := ProxyInfo^.dwAccessType = INTERNET_OPEN_TYPE_PROXY;
      if Result then
      begin
        sProxyResult := AnsiString(ProxyInfo^.lpszProxy);
        i := Pos('http=', sProxyResult) + Length('http=') - 1;
        if (i > 0) then
        begin
          Delete(sProxyResult, 1, i);
          if Length(sProxyResult) > 0 then
          begin
            i := Pos(':', sProxyResult) - 1;
            if (i > 0) then
            begin
              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);
            end;
          end;
        end;
      end
    end;
  finally
    FreeMem(ProxyInfo);
  end;
end;

Open in new window

0
 

Author Closing Comment

by:dirkil2
ID: 31667830
Thank you very much.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
This Micro Tutorial will teach you how to add a cinematic look to any film or video out there. There are very few simple steps that you will follow to do so. This will be demonstrated using Adobe Premiere Pro CS6.
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Suggested Courses

810 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