Jump to content

[Vb.net] How to add proxy to your program.[Proxy code ONLY]


Recommended Posts

Posted

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  

 

 

You will make a button , duble click it and

 

Dim proxy as string = "Proxy IP"
PROXYSET(proxy)
Dim proxy as string = "xxx.xxx.xxx.xxx:8080" 'or  "xxx.xxx.xxx.xxx:80" 

After that you can open every site and your ip will be : xxx.xxx.xxx.xxx

 

Thats all , enjoy

Posted

φιλε το 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

που το βαζω? το δευτερο script μπαινει στο button το πρωτo?

Posted

Έχω την εντύπωση ότι το proxy αυτό λειτουργεί μόνο για I.E. όμως.

Posted

Έχω την εντύπωση ότι το proxy αυτό λειτουργεί μόνο για I.E. όμως.

swsta , aytos to 8elei gia idi iparxon webbrowser , aytos o (default) webbrowser pou xrisimopoiei to .net framework einai o IE opote den iparxei provlima :)
Posted

swsta , aytos to 8elei gia idi iparxon webbrowser , aytos o (default) webbrowser pou xrisimopoiei to .net framework einai o IE opote den iparxei provlima :)

 

Ναι αλλά έχω την εντύπωση ότι χρειάζεται restart o browser ή refresh της σελίδας για να λειτουργήσει ο proxy (αν θυμάμαι καλά γιατί έχω ξαναχρησιμοποιήσει το API αυτό νομίζω.) διόρθωσε με αν κάνω λάθος.

Posted

ΔIKAIO EXEIΣ . ΓIA AYTO KANEIΣ ΠPΩTA ΣET KAI META APXIZEIΣ TON browser (sorry ΓIA TA caps EIMAI AΠO KINHTO)

Posted

ΔIKAIO EXEIΣ . ΓIA AYTO KANEIΣ ΠPΩTA ΣET KAI META APXIZEIΣ TON browser (sorry ΓIA TA caps EIMAI AΠO KINHTO)

xaxaxaxaxaxaax

bro sinexise etsi ;) cool codes

  • 1 month later...
Posted

C# version of code pieces

 

public struct Struct_INTERNET_PROXY_INFO
{
public int dwAccessType;
public IntPtr proxy;
public IntPtr proxyBypass;
}
[Runtime.InteropServices.DllImport("wininet.dll", SetLastError = true)]
private static bool InternetSetOption(IntPtr hInternet, int dwOption, IntPtr lpBuffer, int lpdwBufferLength)
{
}

private void PROXYSET(string strProxy)
{
WebBrowser1.ScriptErrorsSuppressed = true;
const int INTERNET_OPTION_PROXY = 38;
const int INTERNET_OPEN_TYPE_PROXY = 3;
Struct_INTERNET_PROXY_INFO struct_IPI = default(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");
IntPtr intptrStruct = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI));
System.Runtime.InteropServices.Marshal.StructureToPtr(struct_IPI, intptrStruct, true);
bool iReturn = InternetSetOption(IntPtr.Zero, INTERNET_OPTION_PROXY, intptrStruct, System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI));
}

string proxy = "Proxy IP";
[] PROXYSET = new[];
//or  "xxx.xxx.xxx.xxx:80"  
string proxy = "xxx.xxx.xxx.xxx:8080";

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

Important Information

This community uses essential cookies to function properly. Non-essential cookies and third-party services are used only with your consent. Read our Privacy Policy and We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue..