Solved

Disable downloading from program using IE object

Posted on 2002-04-04
4
462 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

SharePoint Admin?

Enable Your Employees To Focus On The Core With Intuitive Onscreen Guidance That is With You At The Moment of Need.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
This article describes how to use a set of graphical playing cards to create a Draw Poker game in Excel or VB6.
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…
Suggested Courses
Course of the Month8 days, 7 hours left to enroll

615 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