Hack Forums
[.NET] [Snippet] Proxy for Webbrowser [VB.net] - Printable Version

+- Hack Forums (https://hackforums.net)
+-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444)
+--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151)
+---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118)
+---- Thread: [.NET] [Snippet] Proxy for Webbrowser [VB.net] (/showthread.php?tid=1364841)



[Snippet] Proxy for Webbrowser [VB.net] - Ethernal Five - Jun 9, 2011

Alot of people were requesting the proxy class for a webbrowser in vb.net, so here it is:

PHP Code

<?php 
Public Structure Struct_INTERNET_PROXY_INFO
  
Public dwAccessType As Integer
  
Public proxy As IntPtr
  
Public proxyBypass As IntPtr
    End Structure
    
<Runtime.InteropServices.DllImport("wininet.dll", SetLastError:=True)> _
    
Private Shared Function InternetSetOption(ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, ByVal lpdwBufferLength As Integer) As Boolean
    End 
Function

    Private 
Sub PROXYSET(ByVal strProxy As String)
  
WebBrowser1.ScriptErrorsSuppressed = True
  
Const INTERNET_OPTION_PROXY As Integer = 38
  
Const INTERNET_OPEN_TYPE_PROXY As Integer = 3
  Dim struct_IPI 
As Struct_INTERNET_PROXY_INFO
  struct_IPI
.dwAccessType = INTERNET_OPEN_TYPE_PROXY
  struct_IPI
.proxy = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi(strProxy)
  
struct_IPI.proxyBypass = System.Runtime.InteropServices.Marshal.StringToHGlobalAnsi("local")
  
Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
  
System.Runtime.InteropServices.Marshal.StructureToPtr(struct_IPI, intptrStruct, True)
  
Dim iReturn As Boolean = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
    
End Sub 

And this is how you use it:
PHP Code

<?php 
Dim proxy 
as string = "Insert you're proxy here"
PROXYSET(proxy) 

Activate it before you run you're webbrowser, so like this:
PHP Code

<?php 
Dim proxy 
as string = "123.123.123.123:80"
PROXYSET(proxy)
Webbrowser1.navigate("https://hackforums.net") 

Feedback appreciated!

This is not made by me! I'm just sharing it with you guys 🤝



* - Tristanpdrec - Jul 15, 2011

Thanks! Worked like a charm!


* - TheBlackMarket - Jul 15, 2011

Really nice, thanks for the sharing.


* - duyan13 - Jul 15, 2011

nice but already post here....^^


* - Ethernal Five - Jul 15, 2011

No problem guys ^^ 25 chars :P


* - HardOwned - Jul 15, 2011

Thanks for sharing mate. :)

-Disguize


* - INFAМOUS - Jul 15, 2011

Good share thanks for this.


* - Ethernal Five - Jul 15, 2011

Thanks alot for you're support ^^


* - Rita Ora - Feb 13, 2012

Thanks for this mate, I have a question:

PHP Code

<?php 
Dim proxy 
as string = "123.123.123.123:80"
PROXYSET(proxy)
Webbrowser1.navigate("https://hackforums.net") 

Instead of "123.123.123.123:80" could you put (Textbox1.Text) and there be a list of proxies in TextBox1? And the equivalent for the link


* - The MammoTh - Feb 13, 2012

@Kandor of course you can. How to pump a old thread.