Solved

Disable downloading from program using IE object

Posted on 2002-04-04
4
423 Views
Last Modified: 2008-02-01
I wrote a browser program using the Microsoft Internet Explorer object.  Is there a way to disable downloading of files inside my program?
0
Comment
Question by:vpl4
  • 2
4 Comments
 
LVL 2

Accepted Solution

by:
Ber earned 50 total points
ID: 6919771
You could evaluate the URL in the BeforeNavigate2 event to see if it is an allowable file type (In other words keep a list of the type of link you will allow the web browser to open such as html,htm,shtml,pl,asp ...etc...

however this would mean that you may end up excluding certain types of pages inadvertantly...

either way once you have evaluated the URL if it is acceptable set cancel to false otherwise set it to true..this is one way of stopping your users downloading files....

Hope this helps..
Cheers...
Ber...


BeforeNavigate2 Event

-----------------------------------------------------------

Fires before a navigation occurs in the given object (on either a window or frameset element).

Syntax

Private Sub object_BeforeNavigate2( _
     ByVal pDisp As Object, _
     ByVal URL As Variant, _
     ByVal Flags As Variant, _
     ByVal TargetFrameName As Variant, _
     ByVal PostData As Variant, _
     ByVal Headers As Variant, _
     ByVal Cancel As Boolean)
Parameters

object
Object expression that resolves to the objects in the Applies To list.

pDisp
Object that evaluates to the top-level or frame WebBrowser object corresponding to the navigation.

URL
String expression that evaluates to the URL to which the browser is navigating.

Flags
Reserved for future use.

TargetFrameName
String expression that evaluates to the name of the frame in which the resource will be displayed, or NULL if no named frame is targeted for the resource.

PostData
Data to send to the server if the HTTP POST transaction is being used.

Headers
Value that specifies the additional HTTP headers to send to the server (HTTP URLs only). The headers can specify such things as the action required of the server, the type of data being passed to the server, or a status code.

Cancel
Boolean value that the container can set to TRUE to cancel the navigation operation, or to FALSE to allow it to proceed.
Error Codes

No return value.
Remarks

Navigating to a different URL could happen as a result of external automation, internal automation from a script, or the user clicking a link or typing in the address bar. The container has an opportunity to cancel the pending navigation


Applies To

WebBrowser
Platform Version
Win32: 4.0
WinCE: 4.0
Version data is listed when the mouse hovers over a link, or the link has focus.
 InternetExplorer, WebBrowser
Move the mouse cursor over an element in the Applies To list to display availability information for the listed platforms. Internet Explorer does not expose this member on platforms that are not listed.
0
 
LVL 39

Expert Comment

by:appari
ID: 6919904
write cancel=true in filedownload event.

here is the details about filedownload event from MSDN online
*********************************
FileDownload Event  
--------------------------------------------------------------------------------

Fires to indicate that a file download is about to occur. If a file download dialog is to be displayed, this event is fired prior to the display of the dialog.

Syntax

Private Sub object_FileDownload( _
     ByRef bCancel As Boolean)
Parameters

object
Object expression that resolves to the objects in the Applies To list.
bCancel
Boolean that specifies whether to continue the download process and display the download dialog.

false
Default. Continue with the download process and display download dialog.
true
Cancel the download process.

Remarks

This event allows alternative action to be taken during a file download.



0
 
LVL 39

Expert Comment

by:appari
ID: 6919906
sorry write bCancel=true in that event
0
 

Author Comment

by:vpl4
ID: 6930010
Thanks Ber, this would allow me to limit certain downloads and not every single one of them.  It is the right thing I needed.
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Introduction I needed to skip over some file processing within a For...Next loop in some old production code and wished that VB (classic) had a statement that would drop down to the end of the current iteration, bypassing the statements that were c…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

14 Experts available now in Live!

Get 1:1 Help Now