Option Explicit On Option Strict On Imports System.Runtime.InteropServices Imports mshtml Imports SHDocVw Imports Shell32 Public Class Form1 Private ListBox1 As New ListBox Private WithEvents Timer1 As New Timer Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Me.Controls.Add(ListBox1) Me.ListBox1.Dock = DockStyle.Fill Me.Timer1.Interval = 1000 Me.Timer1.Start() End Sub Private Sub Form1_FormClosing(sender As Object, e As FormClosingEventArgs) Handles Me.FormClosing Me.Timer1.Stop() End Sub Private Sub Timer1_Tick(sender As Object, e As EventArgs) Handles Timer1.Tick ListBox1.Items.Clear() Dim Shell As Shell = Nothing Dim ShellWindows As ShellWindows = Nothing Try Shell = New Shell ShellWindows = DirectCast(Shell.Windows, ShellWindows) Dim Document As Object = Nothing For Each ie As InternetExplorer In ShellWindows Try If ie.ReadyState >= WebBrowserReadyState.Interactive Then Document = ie.Document If TypeOf Document Is HTMLDocument Then ListBox1.Items.Add(ie.LocationURL) End If End If Catch ex As Exception Finally If Document IsNot Nothing AndAlso Marshal.IsComObject(Document) Then Marshal.FinalReleaseComObject(Document) End If Document = Nothing If ie IsNot Nothing AndAlso Marshal.IsComObject(ie) Then Marshal.FinalReleaseComObject(ie) End If ie = Nothing End Try Next Catch ex As Exception Finally If ShellWindows IsNot Nothing AndAlso Marshal.IsComObject(ShellWindows) Then Marshal.FinalReleaseComObject(ShellWindows) End If ShellWindows = Nothing If Shell IsNot Nothing AndAlso Marshal.IsComObject(Shell) Then Marshal.FinalReleaseComObject(Shell) End If Shell = Nothing End Try End Sub End Class