![]()
|
|
Quellcode |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
Imports System.Net
Imports System.IO
Public Class FaviconDownloader
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
PictureBox1.BackgroundImage = GetFavicon(New Uri(ÜberprüfeURL(TextBox1.Text)))
End Sub
Function GetFavicon(ByVal URl As Uri) As Image
Dim dURl As String = URl.Authority
Dim dieUrl As String = ÜberprüfeURL(dURl) 'Url wird überprüft (http davor gesetzt
Dim Req As WebRequest = WebRequest.Create(dieUrl & "/favicon.ico") 'Eine neue Anfrage wird erstellt für das icon
Dim res As WebResponse = Req.GetResponse 'Die antwort wird geholt
Dim s As New StreamReader(res.GetResponseStream) 'Der Antwort Stream wird ausgelesen mit einem StreamReader
Dim bild As Image = Image.FromStream(s.BaseStream) 'Das Bild wird von dem Stream erstellt
Return bild 'Das Bild wird zurückgegeben
End Function
Function ÜberprüfeURL(ByVal URL As String) As String
Dim fertig As String = URL
If Not fertig.StartsWith("http://") Then fertig = "Http://" & URL
Return fertig
End Function
End Class
|
|
|
Quellcode |
1 |
http://www.vb-paradise.de/index.php?form=PostEdit&postID=126163 |
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »progglord« (14. Juni 2009, 17:35)
Dieser Beitrag wurde bereits 1 mal editiert, zuletzt von »kevin89« (14. Juni 2009, 18:54)