Código: Seleccionar todo

'Function URLVerifie
'Coded By The Swash
'Thanks Skyweb for teach this Apis
'18/01/2010
'[email protected]
'www.Infrangelux.sytes.Net & www.Indetectables.Net
Option Explicit

 Public Declare Function InternetOpen Lib "wininet" Alias "InternetOpenA" (ByVal sAgent As String, ByVal lAccessType As Long, ByVal sProxyName As String, ByVal sProxyBypass As String,  ByVal lFlags As Long) As Long
 Public Declare Function InternetOpenUrl Lib "wininet" Alias "InternetOpenUrlA" (ByVal hInternetSession As Long, ByVal lpszUrl As String, ByVal lpszHeaders As String, ByVal dwHeadersLength As Long, ByVal dwFlags As Long, ByVal dwContext As Long) As Long
 Public Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer

Public Function URLVerifie(sURL As String) As Boolean
 Dim sConect As Long
 Dim URLConect As Long
 
  sConect = InternetOpen("URLVerifie", 0, vbNullString, vbNullString, 0)
   If sConect <> 0 Then URLConect = InternetOpenUrl(sConect, sURL, vbNullString, 0, 0, 0)
   
   If URLConect <> 0 Then
    URLVerifie = True
    Else
    URLVerifie = False
   End If
   
  InternetCloseHandle (sConect)
 InternetCloseHandle (URLConect)
End Function
Sabiendo que hay alternativas como InternetCheckConecction decidi codear este modulo, Skyweb gracias de tus sources aprendi a manejar estas Apis!

Uso:

Código: Seleccionar todo

Private Sub Command1_Click()
 MsgBox IIf(URLVerifie("http://www.google.com"), "Conection Ok", "Fail")
End Sub

'O usando condicion:

Private Sub Command1_Click()
 If URLVerifie("http://www.google.com") = True Then
   xxxx
   Else
   zzzz
  End If
 End Sub
Usado generalmente para downloaders o uso personal!
En tu ventana
Y en tu ventana, gritas al cielo pero lo dices callada..
Mil gracias hermano!...
Si que mejoro usted en VB!The Swash

Salu2
Blog técnico dedicado a la seguridad informática y al estudio de nuevas vulnerabilidades.
Blog: http://www.seginformatica.net
Twitter: https://twitter.com/#!/p0is0nseginf
Responder

Volver a “Otros lenguajes”