title: Delphi TWebBrowser - how to use proxy with login/password?
body: <p>I want to use Delphi VCL-component TWebBrowser with proxy. It seems to be quite easy doing something like this:</p>
  
  <pre><code>var PIInfo: PInternetProxyInfo;
  begin
    PIInfo^.dwAccessType := INTERNET_OPEN_TYPE_PROXY;
    PIInfo^.lpszProxy := PAnsiChar('proxyserver.com:8888');
    PIInfo^.lpszProxyBypass := PAnsiChar('');
    UrlMkSetSessionOption(INTERNET_OPTION_PROXY, PIInfo, SizeOf(Internet_Proxy_Info), 0);
  end;
  </code></pre>
  
  <p>But i also would like to use proxy with authentication. And here i got the trouble. I learned that it is possible to set proxy name and password using WinAPI function InternetSetOption, an example below:</p>
  
  <pre><code>var UserName: AnsiString;
      ConnectionHandle: HINTERNET;
  begin
    // Init ConnectionHandle here 
    //... 
    res := InternetSetOption(ConnectionHandle, 
                             INTERNET_OPTION_PROXY_USERNAME,  
                             UserName, 
                             Length(UserName) + 1);
  end;
  </code></pre>
  
  <p>I learned that InternetSetOption with parameters like INTERNET_OPTION_PROXY_USERNAME could be only applied to the internet handle that was produced by functions like InternetConnect or HttpOpenRequest. </p>
  
  <p>An answer about this can be found <a href="https://stackoverflow.com/questions/15944176/wininetinternetsetoption-always-returns-0-and-getlasterror-returns-1201">here</a>.</p>
  
  <p>It is not a problem, i can call InternetConnect first. But it seems to be not possible after to bind this internet handle to my TWebBrowser. TWebBrowser will ignore these settings because they applied to concrete dedicated internet handle.</p>
  
  <p>So my question: is it possible to setup proxy with authentication in the Delphi-code to use it from TWebBrowser?</p>
  
  <p><strong>PS</strong>. An alternative option is to remember login/password proxy settings when TWebBrowser asks for them but i have multiply logins/passwords so i would like to setup them from the code.</p>
  
  <p>Thank you by advance.</p>