Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Disable downloading from program using IE object

Posted on 2002-04-04
4
Medium Priority
?
480 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 200 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

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
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

885 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