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.