.NET Webbrowser Control mit Proxy nutzen


Will man das .NET Webbrowser Control über einen Proxy nutzen, stellt sich schnell die Frage wie man die Proxy Einstellungen vornehmen kann, denn es gibt keine direkte Möglichkeit einen Proxy zu definieren.
Da es sich beim .NET Webbrowser Control um einen Internet Explorer Clone handelt und dieser auch auf die IE Proxy Settings zurückgreift, liegt es nahe eben diese zu verändern:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
dim proxyip as string
proxyip=TextBox1.Text
'IP des Proxy wird in Textbox1 eingegeben
RefreshIESettings(proxyip)
End Sub

' The structure we use for the information
' to be interpreted correctly by API.
Public Structure Struct_INTERNET_PROXY_INFO
Public dwAccessType As Integer
Public proxy As IntPtr
Public proxyBypass As IntPtr
End Structure

' The Windows API function that allows us to manipulate
' IE settings programmatically.
Private Declare Auto Function InternetSetOption Lib "wininet.dll" _
(ByVal hInternet As IntPtr, ByVal dwOption As Integer, ByVal lpBuffer As IntPtr, _
ByVal lpdwBufferLength As Integer) As Boolean

' The function we will be using to set the proxy settings.
Private Sub RefreshIESettings(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

' Filling in structure
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")

' Allocating memory
Dim intptrStruct As IntPtr = System.Runtime.InteropServices.Marshal.AllocCoTaskMem(System.Runtime.InteropServices.Marshal.SizeOf(struct_IPI))
' Converting structure to IntPtr
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

Quelle: dreamincode.net

Eine andere Möglichkeit die Proxy Einstellungen zu verändern ist es direkt auf die Registry zurückzugreifen.
Wie das geht, erfahrt ihr auf vbarchiv.net
.NET Webbrowser Control mit Proxy nutzen by David Wenzel
@ 21.07.2008, 18:49
Tags:VB.NET


Diese Seite zu Mister Wong hinzufügen

Archiv
1 - 2 - 3 - 4 - 5 - 6 - 7 - 8 - 9 - 10 - 11 - 12 - 13

Blog Home
Tagcloud

Fan von..
SeoFM
Shoutcast
MSDN


Blogroll
Adult Webmaster Blog
S-O-S Seo-Blog
Internetmarketing News
Fridaynite
tentatives verlinken
GoogleWatchBlog
Themenrelevant
Webmaster Blog
Suchmaschinen News

International
SEOmoz
Google Blogoscoped
Aaron Wall
Shoemoney
Matt Cutts

Suchmaschinen Blogs
Alexa
Ask
Google
MSN
Yahoo

RSS Feed

Deine IP
meine ip

Weblog

.NET Webbrowser Control mit Proxy nutzen
Traffic und Verdienst einer TOP 10 Poker Seite
Dies und Das - Improved Flash indexing, Neue Yigg Version, Google Affiliate Network

Seo Tools

Web Utilities

Tutorials

Hilfreich

Informationen

Lexikon

A | B | C | D | E | F | G | H | I | J | K | L | M | N | O | P | Q | R | S | T | U | V | W | X | Y | Z |


Kontakt
David Wenzel
Herforder Straße 48
33602 Bielefeld
0521/3291924
webmaster@stalkpire.org
Suchmaschinenoptimierung