1

我想开发 Internet Explorer 插件。我需要检测用户何时下载文件,但我没有找到相关的事件。在此链接中有一个事件列表,但没有用户开始下载文件的事件

代码示例(从链接中获取):

using mshtml;
using SHDocVw;
class EventHandlers
{
    public void OnBeforeNavigate2(object sender, ref object URL, 
                                  ref object Flags, ref object Target, 
                                  ref object PostData, ref object Headers, 
                                  ref bool Cancel) 
    {
        Console.WriteLine("BeforeNavigate2 fired!");
    }
}

class Program
{
    static void Main(string[] args)
    {
        EventHandlers e = new EventHandlers();
        SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
        object Empty = 0;
        object URL = "http://www.live.com";

        // override BeforeNavigate2 event
        IE.BeforeNavigate2 += new
             SHDocVw.DWebBrowserEvents2_BeforeNavigate2EventHandler(
                     e.OnBeforeNavigate2);

        IE.Visible = true;
        IE.Navigate2(ref URL, ref Empty, ref Empty, ref Empty, ref Empty);

        System.Threading.Thread.Sleep(5000);

        IE.Quit();
    }
}
4

0 回答 0