-
I use the following code to get the size of a website (if theres a better way, please plst below :) )
Code:
Public Function CheckURL(strURL As String, LastModified As String) As Boolean
Dim sBuffer As String * 1024
Dim lBufferLength As Long
Dim strObject As String
'
'connect to the server on HTTP port
'
m_lInternetConnect = InternetConnect(p_lInternetSession, strURL, _
INTERNET_DEFAULT_HTTP_PORT, _
vbNullString, vbNullString, _
INTERNET_SERVICE_HTTP, 0, 0)
'
'prepare HTTP request. We may use "HEAD" command to retrieve
'only response headers, not document itself.
'
m_lHttpRequest = HttpOpenRequest(m_lInternetConnect, "HEAD", _
strObject, "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)
'
'header of the server response. If server has returned content length header
'value of CheckURL will be True and sBuffer will consist value of the header
'
CheckURL = CBool(HttpQueryInfo(m_lHttpRequest, HTTP_QUERY_CONTENT_LENGTH, _
ByVal sBuffer, lBufferLength, 0))
MsgBox CheckURL
End if
If i want to get the size of the file, i use msgbox getsize. However, I only get a response "True"... how can i get the size of the file (without downloading it) and display it in bytes, instead of "True"?
-
You've declared CheckURL serveral times as Boolean so it could only return true or false...
Which references did you create?
(I can't execute it... ;) )
-
sorry.. foolish error :) its supposed to be msgbox sbuffer. then it works :)