Проверка существования URL

Советы » URL » Проверка существования URL

Uses

WinInet;
Function

CheckUrl(Url: String): Boolean; var


hSession : hInternet;
hfile : hInternet;
hRequest : hInternet;
dwindex : DWord;
dwcodelen: DWord;
dwcode : Array [1..20] of Char; res : PChar;
begin
if Pos('http://', LowerCase(Url)) = 0 Then Url := 'http://' + Url; Result := False;
hSession := InternetOpen('InetURL:/1.0', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0); if Assigned(hSession) Then begin
hfile := InternetOpenUrl( Hsession,
Pchar(Url),
nil,
0,
INTERNET_FLAG_RELOAD,
0);
dwIndex := 0;
dwCodeLen := 10;
HttpQueryInfo(hfile, HTTP_QUERY_STATUS_CODE, @dwcode, dwcodeLen, dwIndex); Res := PChar(@dwcode);
Result := (Res ='200') or (Res ='302'); if Assigned(hfile) then InternetCloseHandle(hfile); InternetCloseHandle(hsession); end;
end

;

Другое по теме:

Категории

Статьи

Советы

Copyright © 2022 - All Rights Reserved - www.delphirus.com