In browser programming, how do I get the File Download notification?

Source: Internet
Author: User
Tags blank page

The specific implementation of this method is written by reference to lingll. If you are interested, go to his blog.

 

Everyone who has used ie knows that when downloading and asking for some files, such as forum attachments, a blank page will be created, followed by the pop-up dialog box for saving files, and then close this blank page. Of course it should be closed. This blank page is useless.

 

The question is, how can we get such notifications accurately when downloading files? The answer is to implement the idownloadmanager interface. Practice has proved that the filedownload event is not accurate or useful in some cases.

In addition, the idownloadmanager interface is described as follows:

 

Private sub idownloadmanager_download (byval PMK as olelib. imoniker, byval PBC as olelib. ibindctx, byval dwbindverb as long, byval grfbindf as long, pbindinfo as olelib. bindinfo, byval pszheaders as long, byval pszredir as long, byval UICP as long)

End sub

 

Because at this time, you can use olelib. sysallocstring (PMK. getdisplayname (PBC, nothinglistener) to get the target URL. You can also do a few things. If you do not need to download files such as .html, you can directly return s_ OK. If you only want to get the notification, return inet_e_default_action. Now that you can get the URL, you can call some Downloaders to download it. This is useful for websites that do not allow download tools.

 

Even you can write a simple download tool to directly download the file to a pre-defined directory. Isn't it convenient?

 

After obtaining the download event, it is much simpler. Check whether the current page is a blank page. If yes, close it with code.

 

The function of this interface is far from limited to this. For details, refer to the description of msdn.

 

PS: the implementation of this interface may have minor drawbacks. For more information, see my question:

Http://topic.csdn.net/u/20080603/11/48fc10c6-2808-4fe6-8ae5-df9080d2f096.html

Of course, this can also be solved. This is a post, and we may talk about it later.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.