InternetCrackUrl: Unterschied zwischen den Versionen

Aus API-Wiki
Wechseln zu: Navigation, Suche
(Die Seite wurde neu angelegt: Declare Sub InternetCrackUrl Lib "wininet.dll" _ Alias "InternetCrackUrlA" ( _ ByVal lpszUrl As String, _ ByVal dwUrlLength As L...)
 
K
 
(2 dazwischenliegende Versionen desselben Benutzers werden nicht angezeigt)
Zeile 5: Zeile 5:
 
             ByVal dwFlags As Long, _
 
             ByVal dwFlags As Long, _
 
             ByRef lpUrlComponents As [[URL_COMPONENTSA]])
 
             ByRef lpUrlComponents As [[URL_COMPONENTSA]])
 +
 +
==Beispiel==
 +
 +
Public Function GetURL(ByVal URL As String) As Boolean
 +
Dim COMPONENTS As URL_COMPONENTS
 +
Dim Buffer As String
 +
Dim BufLen As Long
 +
Const BufSize = 1024
 +
     
 +
GetURL = False
 +
   
 +
Buffer = Space$(BufSize)
 +
BufLen = Len(Buffer)
 +
If InternetCanonicalizeUrl(URL, Buffer, BufLen, ICU_BROWSER_MODE) Then
 +
    URL = Left(Buffer, BufLen)
 +
    With COMPONENTS
 +
        .StructSize = Len(COMPONENTS)
 +
        .Scheme = Space$(INTERNET_MAX_SCHEME_LENGTH)
 +
        .SchemeLength = INTERNET_MAX_SCHEME_LENGTH
 +
        .nScheme = InternetSchemeUnknown
 +
        .HostName = Space$(INTERNET_MAX_HOST_NAME_LENGTH)
 +
        .HostNameLength = INTERNET_MAX_HOST_NAME_LENGTH
 +
        .nPort = 0
 +
        .UserName = Space$(INTERNET_MAX_USER_NAME_LENGTH)
 +
        .UserNameLength = INTERNET_MAX_USER_NAME_LENGTH
 +
        .Password = Space$(INTERNET_MAX_PASSWORD_LENGTH)
 +
        .PasswordLength = INTERNET_MAX_PASSWORD_LENGTH
 +
        .URLPath = Space$(INTERNET_MAX_PATH_LENGTH)
 +
        .UrlPathLength = INTERNET_MAX_PATH_LENGTH
 +
        .ExtraInfo = Space$(BufSize)
 +
        .ExtraInfoLength = BufSize
 +
    End With
 +
 
 +
    GetURL = CBool(InternetCrackUrl(URL, Len(URL), ICU_ESCAPE, COMPONENTS))
 +
    With COMPONENTS
 +
        mvarScheme = Left$(.Scheme, .SchemeLength)
 +
        mvarlScheme = .nScheme
 +
        mvarHostName = Left$(.HostName, .HostNameLength)
 +
        mvarUserName = Left$(.UserName, .UserNameLength)
 +
        mvarPassword = Left$(.Password, .PasswordLength)
 +
        mvarURLPath = Left$(.URLPath, .UrlPathLength)
 +
        mvarURLExtraInfo = Left$(.ExtraInfo, .ExtraInfoLength)
 +
        mvarPort = .nPort
 +
    End With
 +
       
 +
End If
 +
 +
End Function
  
 
[[Kategorie:WinInet]]
 
[[Kategorie:WinInet]]

Aktuelle Version vom 7. Mai 2008, 12:06 Uhr

Declare Sub InternetCrackUrl Lib "wininet.dll" _
            Alias "InternetCrackUrlA" ( _
            ByVal lpszUrl As String, _
            ByVal dwUrlLength As Long, _
            ByVal dwFlags As Long, _
            ByRef lpUrlComponents As URL_COMPONENTSA)

Beispiel

Public Function GetURL(ByVal URL As String) As Boolean
Dim COMPONENTS As URL_COMPONENTS
Dim Buffer As String
Dim BufLen As Long
Const BufSize = 1024
      
GetURL = False
   
Buffer = Space$(BufSize)
BufLen = Len(Buffer)
If InternetCanonicalizeUrl(URL, Buffer, BufLen, ICU_BROWSER_MODE) Then
   URL = Left(Buffer, BufLen)
   With COMPONENTS
       .StructSize = Len(COMPONENTS)
       .Scheme = Space$(INTERNET_MAX_SCHEME_LENGTH)
       .SchemeLength = INTERNET_MAX_SCHEME_LENGTH
       .nScheme = InternetSchemeUnknown
       .HostName = Space$(INTERNET_MAX_HOST_NAME_LENGTH)
       .HostNameLength = INTERNET_MAX_HOST_NAME_LENGTH
       .nPort = 0
       .UserName = Space$(INTERNET_MAX_USER_NAME_LENGTH)
       .UserNameLength = INTERNET_MAX_USER_NAME_LENGTH
       .Password = Space$(INTERNET_MAX_PASSWORD_LENGTH)
       .PasswordLength = INTERNET_MAX_PASSWORD_LENGTH
       .URLPath = Space$(INTERNET_MAX_PATH_LENGTH)
       .UrlPathLength = INTERNET_MAX_PATH_LENGTH
       .ExtraInfo = Space$(BufSize)
       .ExtraInfoLength = BufSize
   End With
 
   GetURL = CBool(InternetCrackUrl(URL, Len(URL), ICU_ESCAPE, COMPONENTS))
   With COMPONENTS
       mvarScheme = Left$(.Scheme, .SchemeLength)
       mvarlScheme = .nScheme
       mvarHostName = Left$(.HostName, .HostNameLength)
       mvarUserName = Left$(.UserName, .UserNameLength)
       mvarPassword = Left$(.Password, .PasswordLength)
       mvarURLPath = Left$(.URLPath, .UrlPathLength)
       mvarURLExtraInfo = Left$(.ExtraInfo, .ExtraInfoLength)
       mvarPort = .nPort
   End With
       
End If
End Function