Nov 8, 2019 08:07 AM
(This post was last modified: Nov 8, 2019 09:18 AM by Camf ∆.)
Hey guys, getting back into the VB game 🙂
I've pulled up one of my old projects which helped me access web browsers via a certain proxy to login to a social media account via the selected proxy.
After testing it out, everything still works; but the web browser in visual basics is outdated. I found a workaround using CefSharp and chromium, it seems to work the only issue I'm having after recreating everything using the cefsharp browser is the proxy function isn't working anymore. I'm not getting any errors using the same proxy method as the original program.
Can anyone help me out?
The button that opens up the second browser with proxy and new cefsharp browser:
The code I'm using for the proxy settings:
The code within my 2nd browser containing the cefsharp browser:
adding the UseProxy to the navigate button on form2 didnt do anything :\
I've pulled up one of my old projects which helped me access web browsers via a certain proxy to login to a social media account via the selected proxy.
After testing it out, everything still works; but the web browser in visual basics is outdated. I found a workaround using CefSharp and chromium, it seems to work the only issue I'm having after recreating everything using the cefsharp browser is the proxy function isn't working anymore. I'm not getting any errors using the same proxy method as the original program.
Can anyone help me out?
The button that opens up the second browser with proxy and new cefsharp browser:
Code
Private Sub Button15_Click(sender As Object, e As EventArgs) Handles Button15.Click
Form2.Show()
MessageBox.Show("You are now under proxy " + Label9.Text + " for the account " + Label7.Text)
UseProxy(Label9.Text)
End SubThe code I'm using for the proxy settings:
Code
Imports System.Runtime.InteropServices
Imports CefSharp
Imports CefSharp.WinForms
Public Class Form1
<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 dwAccessType As Integer
Public proxy As IntPtr
Public proxyBypass 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.dwAccessType = INTERNET_OPEN_TYPE_PROXY
struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy)
struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local")
Dim intptrStruct As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI))
Marshal.StructureToPtr(struct_IPI, intptrStruct, True)The code within my 2nd browser containing the cefsharp browser:
Code
Imports System.Runtime.InteropServices
Imports CefSharp
Imports CefSharp.WinForms
Public Class Form2
<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 dwAccessType As Integer
Public proxy As IntPtr
Public proxyBypass 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.dwAccessType = INTERNET_OPEN_TYPE_PROXY
struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy)
struct_IPI.proxyBypass = 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
Private WithEvents browser3 As ChromiumWebBrowser
Public Sub New()
' This call is required by the designer.
InitializeComponent()
' Add any initialization after the InitializeComponent() call.
End Sub
Private Sub Form2_Load(sender As Object, e As EventArgs) Handles MyBase.Load
browser3 = New ChromiumWebBrowser("https://google.com") With {
.Dock = DockStyle.Fill
}
Panel1.Controls.Add(browser3)
End Sub
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
browser3.Load(TextBox1.Text)
End Subadding the UseProxy to the navigate button on form2 didnt do anything :\
Code
Private Sub Button4_Click(sender As Object, e As EventArgs) Handles Button4.Click
UseProxy(Form1.Label9.Text)
browser3.Load(TextBox1.Text)
End Sub
Just a hippie in his bag.


