Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

[TUT][Vb.Net] Use PROXY on WebBrowser [SOURCE]

Hi all... i know that a tut of this is already posted, but not like this...


HOW TO USE PROXY WITH A WEBBROWSER IN VB.NET?

Very simple:

FIRST

Add in the namespace (above the public class form1) this:
Quote:Import System.Runtime.InteropServices



SECOND

UNDER the public Class Form1 add this:
Quote:#region "Using Proxy"
<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

Public Structure Struct_INTERNET_PROXY_INFO
Public DAType As Integer
Public PR As IntPtr
Public PRB As IntPtr
End Structure

Private Sub UseProxy(ByVal strProxy As String)
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.DAType = INTERNET_OPEN_TYPE_PROXY
struct_IPI.PR = Marshal.StringToHGlobalAnsi(strProxy)
struct_IPI.PRB = Marshal.StringToHGlobalAnsi("local")

Dim intptrStruct As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI))

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
#end region



OK, You have finished, this is the usage of this:
Add 2 TextBoxes: In the TextBox1 you must put the IP of the proxy, in the TextBox2 you must put the port. This is the code:
Quote:UseProxy(Textbox1.Text & ":" & Textbox2.Text)


I've made this code by other tutorials, now i've found this code in my folders and i've thought to share this with the comunity.

PLEASE, IF YOU ARE TRYING TO PUT ME -REP, TELL ME WHY BEFORE PLEASE!
May I ask why you include the whole InteropServices Class just to import wininet.dll? Wouldn't it be better to just reference the wininet.dll and use it directly instead of loading extra functions and size into your program?
(Aug 16, 2011 10:00 AM)MelGrim Wrote:  May I ask why you include the whole InteropServices Class just to import wininet.dll? Wouldn't it be better to just reference the wininet.dll and use it directly instead of loading extra functions and size into your program?
Yeah , no offence but you just copy+pasted it without even knowing what the code does
(Aug 16, 2011 10:04 AM)StaTiX Wrote:  Yeah , no offence but you just copy+pasted it without even knowing what the code does

From this thread? https://hackforums.net/showthread.php?tid=1364841
<?php echo "I'm a professional web developer, if you need something ask me."; ?>

(Aug 16, 2011 10:27 AM)ScreamX Wrote:  From this thread? https://hackforums.net/showthread.php?tid=1364841
doubt it , the code down there dosent have
imports system.runtime.interopservices


Possibly Related Threads...
Thread / Author Replies Views Last Post
[.NET] by nathan72389Dec 4, 2021 10:27 AM 7 940 Dec 4, 2021 10:27 AM
Last Post: zatt
[.NET] by D3ath_GuNJan 3, 2020 01:49 PM 4 251 Jan 3, 2020 01:49 PM
Last Post: Krysis
[.NET] by isuDec 25, 2018 03:53 PM 3 200 Dec 25, 2018 03:53 PM
Last Post: StarZ