vb.net webbrowser控件 设置代理IP,webbrowser 代理IP
发布时间:2020-12-16 22:30:53 所属栏目:大数据 来源:网络整理
导读:Imports System.Runtime.InteropServices Public Class Form1 StructLayout(LayoutKind.Sequential) _ Public Structure Struct_INTERNET_PROXY_INFO Public dwAccessType As Integer Public proxy As IntPtr Public proxyBypass As IntPtr End Structure Dl
Imports System.Runtime.InteropServices Public Class Form1 <StructLayout(LayoutKind.Sequential)> _ Public Structure Struct_INTERNET_PROXY_INFO Public dwAccessType As Integer Public proxy As IntPtr Public proxyBypass As IntPtr End Structure
<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 Function RefreshIESettings(ByVal strProxy As String) As Boolean
Dim INTERNET_OPTION_PROXY As Integer = 38 Dim INTERNET_OPEN_TYPE_PROXY As Integer = 3
Dim struct_IPI As Struct_INTERNET_PROXY_INFO
'Filling in structure
struct_IPI.dwAccessType = INTERNET_OPEN_TYPE_PROXY struct_IPI.proxy = Marshal.StringToHGlobalAnsi(strProxy) struct_IPI.proxyBypass = Marshal.StringToHGlobalAnsi("local ")
'Allocating memory
Dim intptrStruct As IntPtr = Marshal.AllocCoTaskMem(Marshal.SizeOf(struct_IPI))
'Converting structure to IntPtr
Marshal.StructureToPtr(struct_IPI,intptrStruct,True)
Return InternetSetOption(IntPtr.Zero,INTERNET_OPTION_PROXY,Marshal.SizeOf(struct_IPI))
End Function
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
RefreshIESettings("192.168.1.150:8080) '使用 IP:端口 WebBrowser1.Navigate(" http://www.ip138.com") End Sub
End Class
(编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |