Option Explicit Private Declare Function InternetCrackUrl Lib "wininet.dll" Alias "InternetCrackUrlA" (ByVal lpszURL As String, ByVal dwUrlLength As Long, ByVal dwFlags As Long, lpUrlComponents As URL_COMPONENTS) As Long Private Declare Function InternetCanonicalizeUrl Lib "wininet.dll" Alias "InternetCanonicalizeUrlA" (ByVal lpszURL As String, ByVal lpszBuffer As String, lpdwBufferLength As Long, ByVal dwFlags As Long) As Long Private Const ICU_BROWSER_MODE = &H2000000 Private Const ICU_ESCAPE = &H80000000 Private Type URL_COMPONENTS StructSize As Long Scheme As String SchemeLength As Long nScheme As Long HostName As String HostNameLength As Long nPort As Long UserName As String UserNameLength As Long Password As String PasswordLength As Long URLPath As String UrlPathLength As Long ExtraInfo As String ExtraInfoLength As Long End Type Private Sub Form_Load() MsgBox FavIcon("http://www.windowsmedia.com/mg/Radio.asp?rf=1#radTop") End Sub Private Function FavIcon(ByVal vsURL As String) As String Dim tURL As URL_COMPONENTS Dim sBuffer As String Dim nLength As Long sBuffer = Space$(1024) nLength = 1024 If InternetCanonicalizeUrl(vsURL, sBuffer, nLength, ICU_BROWSER_MODE) Then vsURL = Strings.Left$(sBuffer, nLength) With tURL .StructSize = LenB(tURL) .Scheme = Space$(32) .SchemeLength = 32 .nScheme = -1 .HostName = Space$(256) .HostNameLength = 256 End With InternetCrackUrl vsURL, Len(vsURL), ICU_ESCAPE, tURL With tURL FavIcon = Strings.Left$(.Scheme, .SchemeLength) & "://" & Strings.Left$(.HostName, .HostNameLength) & "/favicon.ico" End With End If End Function
Vous n’avez pas trouvé la réponse que vous recherchez ?
Posez votre question