Download size and WebBrowser control 
Author Message
 Download size and WebBrowser control


using the WebBrowser control, how can I stop a download started by the
user if the target file size is bigger than 1mb?


Sat, 27 Dec 2003 10:43:46 GMT  
 Download size and WebBrowser control

It's hard to check the file size in the WebBrowser control. You may
consider using Windows API to do so. Establish a separate connection to
check the size before the file is downloaded. Below is the code to check
file size. Hope it is helpful to you.

Option Explicit

Private Sub CheckFileSize()

Dim hInet As Long
Dim hFile As Long
Dim lFileSize As Long
Dim lIndex As Long
Dim lBufferLen As Long

hInet = InternetOpen( _
    "Test", _
    "europroxy", _
    vbNullString, _
Debug.Print "hInet: " & hInet

If hInet = 0 Then
    Exit Sub
End If

hFile = InternetOpenUrl(hInet, "", vbNullString, 0, 0, 0)

Debug.Print "hFile: " & hFile

If hFile = 0 Then
    MsgBox Err.LastDllError
    GoTo Cleanup
End If
lBufferLen = 4

HTTP_QUERY_FLAG_NUMBER, lFileSize, lBufferLen, lIndex) Then
    Debug.Print "HttpQueryInfo -- HTTP_QUERY_CONTENT_LENGTH: " & lFileSize
End If


If hFile Then
    Debug.Print "InternetCloseHandle: " & InternetCloseHandle(hFile)
End If

If hInet Then
    Debug.Print "InternetCloseHandle: " & InternetCloseHandle(hInet)
End If

End Sub

Sun, 28 Dec 2003 19:53:01 GMT  
 [ 2 post ] 

 Relevant Pages 

1. Detect File Download from WebBrowser Control

2. Webbrowser control - Download Bytes

3. Saving images downloaded by WebBrowser control

4. How to Disable Image Download in WebBrowser Control?

5. ExecWB and Zoom: Font Size in WebBrowser Control

6. To change the font size of the text displayed in a WebBrowser control

7. change font size in webbrowser control

8. Setting Scrollbar size in WebBrowser control.

9. Text size in webbrowser control

10. Webbrowser control text size

11. WebBrowser Control - Finding out page size

12. webbrowser control size not flexible


Powered by phpBB® Forum Software