Private Const INTERNET_OPEN_TYPE_PRECONFIG = 0
Private Const INTERNET_OPEN_TYPE_DIRECT = 1
Private Const INTERNET_OPEN_TYPE_PROXY = 3
Private Const scUserAgent = "Microsoft User Agent"
Private Const INTERNET_FLAG_RELOAD = &H80000000
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 InternetOpenUrl Lib "wininet.dll" Alias "InternetOpenUrlA" (ByVal hOpen As Long, ByVal sUrl As String, ByVal sHeaders As String, ByVal lLength As Long, ByVal lFlags As Long, ByVal lContext As Long) As Long
Private Declare Function InternetReadFile Lib "wininet.dll" (ByVal hFile As Long, ByVal sBuffer As String, ByVal lNumBytesToRead As Long, BytesToRead As Long) As Integer
Private Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer
Private Function OpenURL(ByVal sUrl As String) As String
Dim hOpen As Long
Dim hOpenUrl As Long
Dim bRet As Boolean
Dim sReadBuffer As String * 2048
Dim BytesToRead As Long
Dim sBuffer As String
'Подстраиваем адрес. Если в нём есть ошибки.
sUrl = Replace(sUrl, "\", "/")
If Left(sUrl, 7) <> "http://" Then sUrl = "http://" & sUrl
hOpen = InternetOpen(scUserAgent, INTERNET_OPEN_TYPE_PRECONFIG, vbNullString, vbNullString, 0)
hOpenUrl = InternetOpenUrl(hOpen, sUrl, vbNullString, 0, INTERNET_FLAG_RELOAD, 0)
If hOpenUrl = False Then
MsgBox "Подключение не удалось"
Else
Do
sReadBuffer = vbNullString
bRet = InternetReadFile(hOpenUrl, sReadBuffer, Len(sReadBuffer), BytesToRead)
sBuffer = sBuffer & Left$(sReadBuffer, BytesToRead)
Loop Until BytesToRead = 0
End If
If hOpenUrl <> 0 Then InternetCloseHandle (hOpenUrl)
If hOpen <> 0 Then InternetCloseHandle (hOpen)
OpenURL = sBuffer
End Function
Private Sub Form_Activate()
Dim URL As String
Me.Move 0, 0, 10000, 10000
Print "Для перехода на другую страницу - щёлкните по форме." & vbCrLf & String(100, "-")
Print OpenURL(InputBox("Введите адрес.", "xXx", "http://www.mail.ru"))
End Sub
Private Sub Form_Click()
Form_Activate
End Sub
Сейчас этот форум просматривают: SemrushBot, Yandex-бот и гости: 170