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";

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...