jeje sorry, ni lei el post, solo lei el tuyo y pense q era lo otro, pero bueno, si no le vale a el a nosotros si.
un saludo
un saludo
Esta sección te permite ver todos los mensajes escritos por este usuario. Ten en cuenta que sólo puedes ver los mensajes escritos en zonas a las que tienes acceso en este momento.
Mostrar Mensajes MenúCitar
Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Private Const INTERNET_DEFAULT_HTTP_PORT = 80
Private Const INTERNET_SERVICE_HTTP = 3
Private Const INTERNET_FLAG_RELOAD = &H80000000
Private Const ERROR_INSUFFICIENT_BUFFER = 122
Private Const HTTP_QUERY_CONTENT_TYPE = 1
Private Const HTTP_QUERY_CONTENT_LENGTH = 5
Private Const HTTP_QUERY_EXPIRES = 10
Private Const HTTP_QUERY_LAST_MODIFIED = 11
Private Const HTTP_QUERY_PRAGMA = 17
Private Const HTTP_QUERY_VERSION = 18
Private Const HTTP_QUERY_STATUS_CODE = 19
Private Const HTTP_QUERY_STATUS_TEXT = 20
Private Const HTTP_QUERY_RAW_HEADERS = 21
Private Const HTTP_QUERY_RAW_HEADERS_CRLF = 22
Private Const HTTP_QUERY_FORWARDED = 30
Private Const HTTP_QUERY_SERVER = 37
Private Const HTTP_QUERY_USER_AGENT = 39
Private Const HTTP_QUERY_SET_COOKIE = 43
Private Const HTTP_QUERY_REQUEST_METHOD = 45
Private Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String, ByVal lFlags As Long) As Long
Private Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" (ByVal hInternetSession As Long, ByVal sServerName As String, ByVal nServerPort As Integer, ByVal sUsername As String, ByVal sPassword As String, ByVal lService As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function HttpOpenRequest Lib "wininet.dll" Alias "HttpOpenRequestA" (ByVal hHttpSession As Long, ByVal sVerb As String, ByVal sObjectName As String, ByVal sVersion As String, ByVal sReferer As String, ByVal something As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function HttpSendRequest Lib "wininet.dll" Alias "HttpSendRequestA" (ByVal hHttpRequest As Long, ByVal sHeaders As String, ByVal lHeadersLength As Long, sOptional As Any, ByVal lOptionalLength As Long) As Long
Private Declare Function HttpQueryInfo Lib "wininet.dll" Alias "HttpQueryInfoA" (ByVal hHttpRequest As Long, ByVal lInfoLevel As Long, ByRef sBuffer As Any, ByRef lBufferLength As Long, ByRef lIndex As Long) As Long
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Function CheckURL(servidor As String, ruta As String)
Dim sBuffer As String * 1024
Dim lBufferLength As Long
p_lInternetSession = InternetOpen(App.Title, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
m_lInternetConnect = InternetConnect(p_lInternetSession, servidor, INTERNET_DEFAULT_HTTP_PORT, vbNullString, vbNullString, INTERNET_SERVICE_HTTP, 0, 0)
m_lHttpRequest = HttpOpenRequest(m_lInternetConnect, "HEAD", ruta, "HTTP/1.0", vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
If CBool(m_lHttpRequest) Then
'
'prepare string buffer to get server response
'
lBufferLength = Len(sBuffer)
'
'send request to remote server. On this state we need Interent connection.
'If system not connected to Internet, dialog with default RAS entry will
'be showed
'
iRetVal = HttpSendRequest(m_lHttpRequest, vbNullString, 0, 0, 0)
'
'Use HTTP_QUERY_LAST_MODIFIED flag to try to retrieve value of the LastModified
'header of the server response. If server has returned LastModified header
'value of CheckURL will be True and sBuffer will consist value of the header
'
valida = CBool(HttpQueryInfo(m_lHttpRequest, HTTP_QUERY_STATUS_CODE, ByVal sBuffer, lBufferLength, 0))
If sBuffer <> 404 Then
CheckURL = True
Else
CheckURL = False
End If
End If
End Function
Private Sub Command1_Click()
MsgBox CheckURL(Text1.Text, Text2.Text)
End Sub