Article ID: 171271
Article Last Modified on 8/20/2007
Private Declare Function InternetOpen Lib "wininet.dll" _
Alias "InternetOpenA" _
(ByVal lpszCallerName As String, _
ByVal dwAccessType As Long, _
ByVal lpszProxyName As String, _
ByVal lpszProxyBypass As String, _
ByVal dwFlags As Long) As Long
Private Declare Function InternetConnect Lib "wininet.dll" _
Alias "InternetConnectA" _
(ByVal hInternetSession As Long, _
ByVal lpszServerName As String, _
ByVal nProxyPort As Integer, _
ByVal lpszUsername As String, _
ByVal lpszPassword As String, _
ByVal dwService As Long, _
ByVal dwFlags As Long, _
ByVal dwContext As Long) As Long
Private Declare Function HttpOpenRequest Lib "wininet.dll" _
Alias "HttpOpenRequestA" _
(ByVal hInternetSession As Long, _
ByVal lpszVerb As String, _
ByVal lpszObjectName As String, _
ByVal lpszVersion As String, _
ByVal lpszReferer As String, _
ByVal lpszAcceptTypes As Long, _
ByVal dwFlags As Long, _
ByVal dwContext 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, _
ByVal sOptional As String, _
ByVal lOptionalLength As Long) As Boolean
Private Declare Function HttpQueryInfo Lib "wininet.dll" _
Alias "HttpQueryInfoA" _
(ByVal hHttpRequest As Long, _
ByVal lInfoLevel As Long, _
ByVal sBuffer As Any, _
ByRef lBufferLength As Long, _
ByRef lIndex As Long) As Boolean
Private Declare Function InternetCloseHandle Lib "wininet.dll" _
(ByVal hInternetHandle As Long) As Boolean
Private Sub Command1_Click()
Dim hInternetOpen As Long
Dim hInternetConnect As Long
Dim hHttpOpenRequest As Long
Dim bRet As Boolean
hInternetOpen = 0
hInternetConnect = 0
hHttpOpenRequest = 0
' Use registry access settings.
Const INTERNET_OPEN_TYPE_PRECONFIG = 0
hInternetOpen = InternetOpen("http generic", _
INTERNET_OPEN_TYPE_PRECONFIG, _
vbNullString, _
vbNullString, _
0)
If hInternetOpen <> 0 Then
' Type of service to access.
Const INTERNET_SERVICE_HTTP = 3
Const INTERNET_DEFAULT_HTTP_PORT = 80
hInternetConnect = InternetConnect(hInternetOpen, _
"www.microsoft.com", _
INTERNET_DEFAULT_HTTP_PORT, _
vbNullString, _
"HTTP/1.0", _
INTERNET_SERVICE_HTTP, _
0, _
0)
If hInternetConnect <> 0 Then
' Brings the data across the wire even if it locally cached.
Const INTERNET_FLAG_RELOAD = &H80000000
hHttpOpenRequest = HttpOpenRequest(hInternetConnect, _
"HEAD", _
"default.htm", _
vbNullString, _
vbNullString, _
0, _
INTERNET_FLAG_RELOAD, _
0)
If hHttpOpenRequest <> 0 Then
bRet = HttpSendRequest(hHttpOpenRequest, _
vbNullString, _
0, _
vbNullString, _
0)
' Headers to query
Const HTTP_QUERY_CONTENT_TYPE = 1
Const HTTP_QUERY_VERSION = 18
Const HTTP_QUERY_SERVER = 37
Const HTTP_QUERY_REQUEST_METHOD = 45
If bRet Then
Dim sBuff As String * 1024
Dim lBuffLen As Long
lBuffLen = Len(sBuff)
'response headers
If (HttpQueryInfo(hHttpOpenRequest, _
HTTP_QUERY_CONTENT_TYPE, sBuff, lBuffLen, 0) _
= 1) Then
List1.AddItem sBuff
End If
If (HttpQueryInfo(hHttpOpenRequest, _
HTTP_QUERY_VERSION, sBuff, lBuffLen, 0) _
= 1) Then
List1.AddItem sBuff
End If
If (HttpQueryInfo(hHttpOpenRequest, _
HTTP_QUERY_SERVER, sBuff, lBuffLen, 0) _
= 1) Then
List1.AddItem sBuff
End If
If (HttpQueryInfo(hHttpOpenRequest, _
HTTP_QUERY_REQUEST_METHOD, sBuff, lBuffLen, 0) _
= 1) Then
List1.AddItem sBuff
End If"?> Dim sBuff As String * 1024
Dim lBuffLen As Long
lBuffLen = Len(sBuff)
'response headers
If (HttpQueryInfo(hHttpOpenRequest, _ HTTP_QUERY_CONTENT_TYPE, sBuff, lBuffLen, 0) _ = 1) Then
List1.AddItem sBuff
End If
lBuffLen = Len(sBuff)
If (HttpQueryInfo(hHttpOpenRequest, _ HTTP_QUERY_VERSION, sBuff, lBuffLen, 0) _ = 1) Then
List1.AddItem sBuff
End If
lBuffLen = Len(sBuff)
If (HttpQueryInfo(hHttpOpenRequest, _ HTTP_QUERY_SERVER, sBuff, lBuffLen, 0) _ = 1) Then
List1.AddItem sBuff
End If
lBuffLen = Len(sBuff)
If (HttpQueryInfo(hHttpOpenRequest, _ HTTP_QUERY_REQUEST_METHOD, sBuff, lBuffLen, 0) _ = 1) Then
List1.AddItem sBuff
End If
End If
End If
End If
End If
' Close all handles
If hInternetOpen <> 0 Then
bRet = InternetCloseHandle(hInternetOpen)
End If
If hInternetConnect <> 0 Then
bRet = InternetCloseHandle(hInternetConnect)
End If
If hHttpOpenRequest <> 0 Then
bRet = InternetCloseHandle(hHttpOpenRequest)
End If
End Sub
170365 : INFO: Visual Studio 97 Service Packs - What, Where, and Why
171554 : INFO: Visual Basic 5.0 Fixes in Visual Studio 97 Service Pack 2
Private Sub Command1_Click()
Dim strURL As String
strURL = "http://www.microsoft.com"
Inet2.Execute URL:=strURL, Operation:="HEAD"
End Sub
Keywords: kbbug kbfix kbvbp500sp2fix kbvs97sp2fix KB171271