IMHO.WS

IMHO.WS (https://www.imho.ws/index.php)
-   Программирование (https://www.imho.ws/forumdisplay.php?f=40)
-   -   помогите (URL prof) (https://www.imho.ws/showthread.php?t=55623)

Mind 04.04.2004 08:13

помогите (URL prof)
 
vot proga
ona proveraet syzestvovanie URL.
a kak iz nee perevesti polychenoe v kakoi nibyd label1.caption ili echo cho ni byd?
-------------------------------------------------------
uses wininet;

function CheckUrl(url: string): boolean;
var
hSession, hfile, hRequest: hInternet;
dwindex, 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;
----------------------------------------------------------

V@nya 04.04.2004 13:03

Mind, если тебе надо чтобы в лейбеле отображался результат, то пиши:
if CheckUrl('http://imho.ws')=true then label1.caption='Такой урл есть';
else label1.caption='Такого урла нет';

А если недо чтобы функция проверяла урл из лейбела, то:
b= CheckUrl(label1.caption); {b типа boolean}

В коде могут быть ошибки, т.тк паскаль(дельфи) я почти не знаю (раньше чуть-чуть учил паскаль)


Часовой пояс GMT +4, время: 03:50.

Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2026, Jelsoft Enterprises Ltd.