Ver Mensaje Individual
  #2  
Antiguo 29-10-2008
Fistandantilus Fistandantilus is offline
Miembro
 
Registrado: ago 2008
Posts: 10
Reputación: 0
Fistandantilus Va por buen camino
Fijate si esto te sirve.

tenes q meter la libreria WinInet

Código Delphi [-]
function TPreferencesForm.GetURLStatus(aURL: String): Integer;
var
   hInet, hConecction, httprequest: HINTERNET;
   Host, Page: String;
   size, Reserved: Cardinal;
   Head: Array [0..1024] of Char;
begin
   Result := -1;
   Reserved := 0;
   hInet := nil;
   hConecction := nil;
   httprequest := nil;
   if (aURL <> '') then begin
      try
         hInet := InternetOpen('lo q kieras', INTERNET_OPEN_TYPE_PRECONFIG, nil, nil, 0);
         if Assigned(hInet) then begin
            AnsiReplaceStr(aURL, 'http://', '');
            if (Pos('/', aURL) > 0) then begin
               Host := Copy(aURL, 1, Pos('/', aURL)-1);
               Page := Copy(aURL, Pos('/', aURL)+1, Length(aURL));
            end else begin
               Host := aURL;
               Page := '';
            end;
            hConecction := InternetConnect(hInet, PAnsiChar(Host), INTERNET_DEFAULT_HTTP_PORT, nil, nil, INTERNET_SERVICE_HTTP, 0, 0);
            if Assigned(hConecction) then begin
               HttpRequest := HttpOpenRequest(hConecction, 'HEAD', PAnsiChar(Page), nil, nil, nil, INTERNET_FLAG_KEEP_CONNECTION, 0);
               if Assigned(HttpRequest) then begin
                  if (HttpSendRequest(HttpRequest, nil, 0, nil, 0)) then begin
                     size := SizeOf(Head);
                     HttpQueryInfo(HttpRequest, HTTP_QUERY_STATUS_CODE, @Head, size, reserved);
                     if (String(Head) <> '') then begin
                        try
                           Result := StrToInt(String(Head));
                        except
                           Result := -6;
                        end;
                     end else begin
                        Result := 0;
                     end;
                  end else begin
                     Result := -5;
                  end;
               end else begin
                  Result := -4;
               end;
            end else begin
               Result := -3;
            end;
         end else begin
            Result := -2;
         end;
      finally
         if Assigned(hInet) then InternetCloseHandle(hInet);
         if Assigned(hConecction) then InternetCloseHandle(hConecction);
         if Assigned(HttpRequest) then InternetCloseHandle(HttpRequest);
      end;
   end;

end;

Espero q te sirva

saludos
Responder Con Cita