Solved

Disable downloading from program using IE object

Posted on 2002-04-04
4
448 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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

726 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