![]() |
URL in die Bestandteile zerlegen
Folgende Procedure zerlegt eine URL in Ihre Einzelbestandteile.
Entstanden ist der Code nach einer Anregung von ![]() Die Unit WinInet muss eingebunden werden.
Delphi-Quellcode:
[edit=Matze]Code formatiert. Mfg, Matze[/edit]
type
TEasyURLComponents = record Scheme, HostName: string; Port: Integer; User, Password, UrlPath, ExtraInfo: string; end; procedure CrackURL(const URL: string; decode, escape: Boolean; var data: TEasyURLComponents ); var uc: TURLComponents; flags: Cardinal; begin ZeroMemory(@uc, sizeof(uc)); uc.dwStructSize := sizeof(TURLComponents); with data do begin SetLength(Scheme, 10); uc.lpszScheme := PChar(Scheme); uc.dwSchemeLength := Length(Scheme); SetLength(HostName, 200); uc.lpszHostName := PChar(HostName); uc.dwHostNameLength := Length(HostName); SetLength(User, 200); uc.lpszUserName := PChar(User); uc.dwUserNameLength := Length(User); SetLength(Password, 200); uc.lpszPassword := PChar(Password); uc.dwPasswordLength := Length(Password); SetLength(UrlPath, 1000); uc.lpszUrlPath := PChar(UrlPath); uc.dwUrlPathLength := Length(UrlPath); SetLength(ExtraInfo, 2000); uc.lpszExtraInfo := PChar(ExtraInfo); uc.dwExtraInfoLength:= Length(ExtraInfo); end; flags := 0; // Converts encoded characters back to their normal form. if decode then flags := flags or ICU_DECODE; // Converts all escape sequences (%xx) to their corresponding characters. if escape then flags := flags or ICU_ESCAPE; if not InternetCrackUrl(PChar(URL), Length(URL), flags, uc) then RaiseLastWin32Error; with data do begin SetLength(Scheme, uc.dwSchemeLength); SetLength(HostName, uc.dwHostNameLength); SetLength(User, uc.dwUserNameLength); SetLength(Password, uc.dwPasswordLength); SetLength(UrlPath, uc.dwUrlPathLength); SetLength(ExtraInfo, uc.dwExtraInfoLength); Port := uc.nPort; end; end; |
Alle Zeitangaben in WEZ +1. Es ist jetzt 21:51 Uhr. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024 by Thomas Breitkreuz