[AUTOSOLVED! :) ) Set proxy to WebGadget fails

Just starting out? Need help? Post your questions and find answers here.
zikitrake
Addict
Addict
Posts: 834
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

[AUTOSOLVED! :) ) Set proxy to WebGadget fails

Post by zikitrake »

Solved! :D, Just changed this line

Code: Select all

PIInfo\lpszProxy = @ProxyServer
to

Code: Select all

PIInfo\lpszProxy = AllocateMemory(Len(ProxyServer))
PokeS(PIInfo\lpszProxy, ProxyServer, Len(ProxyServer), #PB_Ascii)
A few days ago I found this code to set a proxy to a webgadget, but something will have changed because it does not work (PB 5.62 x86, Windows 10 64)

Results when I do a right-click->Reload:
Image

Compile it in with PB x86 (in PB x64 it don't affect to the configuration)

Code: Select all

Structure INTERNET_PROXY_INFO
  dwAccessType.l
  *lpszProxy
  *lpszProxyBypass
EndStructure
Debug SizeOf(INTERNET_PROXY_INFO)

#INTERNET_OPTION_PROXY=38
#INTERNET_OPEN_TYPE_PROXY = 3
#INTERNET_OPEN_TYPE_DIRECT = 1

Procedure NewIE_Proxy(Proxy.s, Port, State.c)
  ProxyServer.s=Proxy+":"+Str(Port)
  
  If State=1
    Flags=#INTERNET_OPEN_TYPE_PROXY
  Else
    Flags=#INTERNET_OPEN_TYPE_DIRECT
  EndIf
  
  PIInfo.INTERNET_PROXY_INFO
  PIInfo\dwAccessType    = Flags
  
  ;  PIInfo\lpszProxy        = @ProxyServer
;  **** change previous line to this 2 lines ***
  PIInfo\lpszProxy = AllocateMemory(Len(ProxyServer))
  PokeS(PIInfo\lpszProxy, ProxyServer, Len(ProxyServer), #PB_Ascii)
  
  PIInfo\lpszProxyBypass    = @"l"
  Debug SizeOf(INTERNET_PROXY_INFO)
  If UrlMkSetSessionOption_(#INTERNET_OPTION_PROXY, @PIInfo, SizeOf(INTERNET_PROXY_INFO), 0)=#S_OK
    x=1
  Else
    x=0
  EndIf
  ProcedureReturn x
EndProcedure

Procedure NewIE_Silent(IE_gadget.l, status.b = #True)
  Define browser.IWebBrowser2  
  SetGadgetAttribute(IE_gadget,#PB_Web_BlockPopups,#True)
  browser = GetWindowLongPtr_(GadgetID(IE_gadget), #GWL_USERDATA) 
  ;webtab
  If browser: browser\put_Silent(#True): EndIf
EndProcedure


NewIE_Proxy("14.139.225.83",3128, 1)

If OpenWindow(0, 0, 0, 800, 600, "WebGadget", #PB_Window_SystemMenu | #PB_Window_ScreenCentered) 
  WebGadget(0, 10, 10, 780, 580, "www.mon-ip.com") 
  NewIE_Silent(0,#True)
  Repeat 
    Event=WaitWindowEvent()
  Until Event = #PB_Event_CloseWindow 
EndIf

NewIE_Proxy("", 0, 0);
Does anyone have a clue to make it functional?

Thank you thousands! and sorry my bad english!
Last edited by zikitrake on Wed Oct 17, 2018 2:47 pm, edited 12 times in total.
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Set proxy to WebGadget fails

Post by Marc56us »

I don't understand much about this code. Does it do something more than the new HTTPProxy() function that appeared with PB 5.60 and works very well with WebGadget ?

:idea: This code is from 2010. Prefer the use of the search functions of the internal forum because it ranks by date unlike Google which ranks by popularity and therefore very often shows stuff that has worked, but is often obsolete because the functions have been implemented in PB since then.

:wink:
zikitrake
Addict
Addict
Posts: 834
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Re: Set proxy to WebGadget fails

Post by zikitrake »

Marc56us wrote:I don't understand much about this code. Does it do something more than the new HTTPProxy() function that appeared with PB 5.60 and works very well with WebGadget ?

:idea: This code is from 2010. Prefer the use of the search functions of the internal forum because it ranks by date unlike Google which ranks by popularity and therefore very often shows stuff that has worked, but is often obsolete because the functions have been implemented in PB since then.

:wink:
:? I tried HTTProxy, but it doesn't seem to affect Webgadget. I get the same result as in my initial post (my own IP)

From PB manual:
HTPProxy(URL$ [, User$, Password$])
Description
Specify a proxy to use for the following HTTP commands: GetHTTPHeader(), ReceiveHTTPFile() and ReceiveHTTPMemory().
Marc56us
Addict
Addict
Posts: 1479
Joined: Sat Feb 08, 2014 3:26 pm

Re: Set proxy to WebGadget fails

Post by Marc56us »

You're right, I didn't pay attention to that line. I saw my proxy icon running with the WebGadget because my anti-advertising proxy was configured in the system itself (at Windows level) :oops:
zikitrake
Addict
Addict
Posts: 834
Joined: Thu Mar 25, 2004 2:15 pm
Location: Spain

Re: Set proxy to WebGadget fails

Post by zikitrake »

:( First post updated, It seems that the proxy that activates is 1:80 :?:

Image
Post Reply