Option Explicit
'======================================================================
' º Function : GetHtmlCode
' º Author : Mr.Frog ©
' º Country : Spain
' º Mail : vbpsyke1@mixmail.com
' º Twitter : http://twitter.com/#!/PsYkE1
' º Recommended Websites :
' http://foro.h-sec.org
' http://InfrAngeluX.Sytes.Net
'======================================================================
Private 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
Private 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
Private Declare Function InternetReadFile Lib "wininet" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, lNumberOfBytesRead As Long) As Integer
Private Declare Function InternetCloseHandle Lib "wininet" (ByVal hInet As Long) As Integer
Private Declare Function InternetGetConnectedState Lib "wininet.dll" (ByRef lpdwFlags As Long, ByVal dwReserved As Long) As Long
Private Const IF_NO_CACHE_WRITE& = &H4000000
Public Function GetHtmlCode(ByRef strURL$) As String
Dim lngInternet&, lngFile&, lngRead&
Dim strBuffer As String * &H3E8
If InternetGetConnectedState(&H0, &H0) Then
lngInternet = InternetOpen(&H0, &H1, vbNullString, vbNullString, &H0)
If lngInternet Then
lngFile = InternetOpenUrl(lngInternet, strURL, vbNullString, &H0, IF_NO_CACHE_WRITE, &H0)
If lngFile Then
Do
InternetReadFile lngFile, strBuffer, &H3E8, lngRead
DoEvents
GetHtmlCode = GetHtmlCode & Left$(strBuffer, lngRead)
Loop While lngRead
End If
InternetCloseHandle lngInternet
End If
End If
End Function
Private Sub Form_Load()
Debug.Print GetHtmlCode("http://google.com")
End Sub
DoEvents!