TWebbrowser and proxy settings problem [Edit]

Hi
I use a TWebBrowser and I need to add proxy settings. To do it I use this code:

function SetProxy(UserAgent, Address: string): Boolean;
var
  list: INTERNET_PER_CONN_OPTION_LIST;
  dwBufSize: DWORD;
  hInternet: Pointer;
  Options :array[1..3] of INTERNET_PER_CONN_OPTION;
begin
  Result := False;
  dwBufSize := sizeof(list);
  list.dwSize := sizeof(list);
  list.pszConnection := Nil;
  list.dwOptionCount:= High(Options);
  Options[1].dwOption := INTERNET_PER_CONN_FLAGS;
  Options[1].Value.dwValue := PROXY_TYPE_DIRECT or PROXY_TYPE_PROXY;
  Options[2].dwOption := INTERNET_PER_CONN_PROXY_SERVER;

  {$IFDEF UNICODE}
    Options[2].Value.pszValue := PAnsiChar(AnsiString(Address));
  {$Else}
    Options[2].Value.pszValue := PChar(Address);
  {$EndIf}

  Options[3].dwOption := INTERNET_PER_CONN_PROXY_BYPASS;
  Options[3].Value.pszValue  := '<local>';

  list.pOptions := @Options;

  hInternet := InternetOpen(PChar(UserAgent), INTERNET_OPEN_TYPE_DIRECT, nil, nil, 0);
  if hInternet <> nil then
  try
    Result := InternetSetOption(hInternet, INTERNET_OPTION_PER_CONNECTION_OPTION, @list, dwBufSize);
    Result := InternetSetOption(hInternet, INTERNET_OPTION_REFRESH, nil, 0);
  finally
    InternetCloseHandle(hInternet)
  end;
end;


It works very well on Delphi 7 but if I try to compile my application in Delphi 2010 I have a problem, after I call SetProxy function TWebBrowser works always also with fake proxy settings (for example address=999.999.999.999:9999). In Delphi 2010 TWebBrowser don't use the proxy but a direct connection also after SetProxy function.

Can you help me to underestand why?

Edited by: Martin Masci on Apr 2, 2010 7:30 AM
0
Martin
4/2/2010 2:30:12 PM
embarcadero.delphi.winsock 1874 articles. 2 followers. Follow

1 Replies
2177 Views

Similar Articles

[PageSpeed] 1

<Martin Masci> wrote in message news:229622@forums.embarcadero.com...

>  {$IFDEF UNICODE}
>    Options[2].Value.pszValue := PAnsiChar(AnsiString(Address));
>  {$Else}
>    Options[2].Value.pszValue := PChar(Address);
>  {$EndIf}

You should not do that.  The INTERNET_PER_CONN_OPTION is fully 
Unicode-enabled.  Remove the UNICODE check and just use the PChar() cast 
always.

> It works very well on Delphi 7 but if I try to compile my
> application in Delphi 2010 I have a problem, after I call
> SetProxy function TWebBrowser works always also
> with fake proxy settings (for example address=999.999.999.999:9999).

Your UNICODE check is making your code assign a PAnsiChar (and an invalid 
one at that!) where a PWideChar is expected instead.

--
Remy Lebeau (TeamB)
0
Remy
4/4/2010 12:50:55 AM
Reply:

Similar Artilces:

Delphi XE5 TWebBrowser Problem on Android [Edit]
I have write 4 samples code: 1) paginaweb:='file://'+pathpdf+'prova.pdf'; webbrowser1.URL:=paginaweb; 2) paginaweb:='http://www.ufficiotecnicogecom.com/Volantini/prova.pdf'; webbrowser1.URL:=paginaweb; 3) have used webbrowser1.Navigate(paginaweb); 4) paginaweb := 'http://www.youtube.com/user/SisaCentroSudGecom'; webbrowser1.Navigate(paginaweb); or webbrowser1.URL:=paginaweb; webbroser1 is in a mobile form. All not work on Android but work fine on iOS, the case of youtube url load page but still stuck on loading vide...

Windows Update problem through proxy
Hello All, If I enable the setting "Enable Persistent Connections to Origin Servers" Windows update will work without any problem. But it affecting the other sites. For examle , We are trying to connect from a Web application to a site "viewprograms.watchit.com" to open on line courses.I am unable to read the pages from the site. If I disable the setting "Enable Persistent Connections to Origin Servers" the above mentiones site will work fine. Can anybody suggest any solution for this? Thanks in advance NSMK Nagalaseema, It app...

Delphi 2006 to Delphi XE Crystal BPL problem [Edit]
I am in the process of migrating our application from Delphi 2006 to Delphi XE and, for ease of use, I have both 2006 and XE installed on my development computer. I access Crystal Reports XI RDC in our application and so I rebuilt the BPL in XE in order to add the new package to XE. However, when I try to add the package to XE I get the error message: “Registration procedure, Craxddrt_tbl.Register in the package c:\Documents and Settings\All Uers\Documents\RADS Studio\8.0\BPL\Crystal.bpl raised exception class EFilerError: Component TDatabase can’t be registered by package crystal.bpl be...

Proxy setting problem
Name: Horace Email: gt4a03atyahoodotcomdothk Product: Firefox Summary: Proxy setting problem Comments: The automatic proxysetting doesn't work, and i need to change it again if i need to use other network Browser Details: Mozilla/5.0 (Windows; U; Windows NT 6.0; en-GB; rv:1.9.1b2) Gecko/20081201 Firefox/3.1b2 From URL: http://hendrix.mozilla.org/ Note to readers: Hendrix gives no expectation of a response to this feedback but if you wish to provide one you must BCC (not CC) the sender for them to see it. ...

Problem with Proxy Setting
Last week I posted this request for help with an ill behaving proxy setting in Firefox. It was suggested that I post in this newsgroup. I hope someone can help. We have two different profiles for FF 1.5 running dial-up on an XP Pro machine with SP2 installed. Our Norton Internet Security is set to allow all connections for FF. Our problem is that only one of the profiles will set our localhost proxy properly. Both profiles should be using the same proxy setting of "localhost:8080 with and exception for 127.0.0.1". Since we don't open both profiles at the ...

Problem using InstallAware 7 CodeGear Special Edition with Delphi 2010 [Edit]
Hi Everyone, I am trying to create an installation disk for my delphi 2010 application using the installAware that kind of comes with Delphi 2010. When I try to built it, it keeps giving me the error message:- No files matching pattern "C:\Windows\system32\\*120.bpl" and when I look into my windows\system32 folder, there the files with extension *.bpl end with *140.bpl and not *120.bpl like it was expected. Can anyone tell me if I am doing something wrong or how I can get around this. Thanks in advance. Edited by: Tat Hon Chu on Dec 3, 2009 12:55 AM > {quo...

[Help] Setting Proxy Problems
Firstly, I want to state that I'm really new in Linux and also I'm not really good in networking stuff. I use Wi-Fi (WPA) connection in my school. I followed the guide on how to setting the proxy for Konqueror and Firefox. They work perfectly fine. I tried to set proxy for Google Chrome, I did realize Google Chrome use the same setting as Konqueror. I thought it might be working. But, when I tried to surf using Google Chrome, it's not working. The request always times out. What should I do to fix it up? I do really need Google Chrome, because it does help me with...

Problem with editing module settings
HiI just put an Annoucement module on my website.When I enter settings for this module I can not open advanced settings, I clik on + but nothing happens!Its the same when I try to open page settings.How can it be I can not do this?I expirenced this before, but vack then I reinstalled DNN again, I do not want to do this now!RegardsJens Thomsen, DenmarkRegards Trisect Development Want to remember your passwords Try Trisect Password Keeper on www.trisect.dk First try it with another browser. I'm not very familiar with the new client API, but it could also be that the referenced .js files a...

Problem with konqueror proxy settings
Hello, can anybody help me to solve the following problem? I tried to configure a proxy connection with the Konqueror web browser (not with the default proxy settings) and now the browser works no more: it seams to load, but after some seconds the loading icon disappears. A Konqueror process appears in the Performance Monitor (as silent), but I have to kill it because indeed no Konqueror windows appears. I tried to reinstall Konqueror via Yast, but it still doesn't work. I precise that usually I go on the web with Firefox, but as sometimes I need to use a connection via a ...

TWebBrowser in Delphi 2009 [Edit]
I'm having a strange problem with TWebBrowser in Delphi 2009. If you take a TWebBrowser from the palette, put it on a form, then it works :) However, if you put the TWebBrowser control and put it on a form, and then open the form as a child window, it does not work. By 'child' window I don't mean anything to do with MDI; rather I mean opening one form almost as a control onto another (in order words, a Petzold 'child'). Code showing how this is done is posted below. This has not been a problem in earlier versions of Delphi. Something has changed. If someone cou...

Having problem with TWebBrowser on frame [Edit]
I set all of this up on a form and it worked beautifully. I then transferred it to a frame and now I get the error "Undeclared identifier 'WebBroswer1' at line 263. Below is the code in the unit and yes I have removed stuff that didn't apply to this issue to simplify this posting. What am I doing wrong here that Delphi XE doesn't recognize that there is indeed a TWebbrowser already declared? FYI this frame goes on a tabsheet on a pagecontrol on the main form. Thanks, TD {code} unit Picks; interface uses Windows, Messages, SysUtils, Variants, Class...

Delphi Designer Problem [Edit]
An older Delphi application consisting of many projects (a host exe and several plug in libraries) was thrown my way today and it has a problem. The problem lies in the way Delphi is choosing which designer to use when displaying a data module for one particular plug in library project. Each plug in library has one data module which inherits from a shared base data module unit. The base data module published some new properties like version (string), serial (string), and security (integer), etc. In all the plug in library projects, when you open the derived data module Delphi picks the ...

Problem with editing a modules settings
Sorry doubble post!!Regards Trisect Development Want to remember your passwords Try Trisect Password Keeper on www.trisect.dk...

Delphi
Hi, I'm trying to make an application that connects to the specyfic device and read some data... thay are in strings... Device producer give Delphi library that works but instead of number (string with number '1234.67') I get kind of chinesse letters.. if I do AnsiString := String there is '??????d' string instead od chinnesse :-) with other string I get without last letter i.e.: 'Unknow'. http://i.imgur.com/jP47wgC.png The library was made for Delphi 7 and is open in XE5... In future I'd like to use it in FMX also... Sebastian wrote: > I&#...

Web resources about - TWebbrowser and proxy settings problem [Edit] - embarcadero.delphi.winsock

Getting TWebBrowser on iOS to zoom
... := TUIWebView.Create; FWebView.setScalesPageToFit(true); // Add this line of code FDelegate := TiOSWebViewDelegate.Create; FDelegate.SetWebBrowser(Self); ...

Embarcadero AppMethod: another route to cross-platform mobile, now with C++ support
Embarcadero has updated AppMethod, its IDE for cross-platform mobile and desktop applications. The IDE now supports C++, and as a special offer, ...

Resources last updated: 12/24/2015 9:53:16 PM