I just tried it like this and seems to work, when explorer is restarted the WM_IECrashNotify message was detected.
' FORM CODE
Code:
Option Explicit
Private Sub Form_Load()
Hook Me.hWnd
End Sub
Private Sub Form_Unload(Cancel As Integer)
Unhook Me.hWnd
End Sub
' MODULE CODE
Code:
Option Explicit
Private Const GWL_WNDPROC = (-4)
Private Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal HWND As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
Private Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal HWND As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Public Declare Function RegisterWindowMessage Lib "user32" Alias "RegisterWindowMessageA" (ByVal lpString As String) As Long
Private PrevWin As Long
Private WM_IECrashNotify As Long
Public Sub Unhook(handle As Long)
If PrevWin Then
Call SetWindowLong(handle, GWL_WNDPROC, PrevWin)
PrevWin = 0
End If
End Sub
Public Sub Hook(handle As Long)
If PrevWin = 0 Then
WM_IECrashNotify = RegisterWindowMessage("TaskbarCreated")
PrevWin = SetWindowLong(handle, GWL_WNDPROC, AddressOf Win_Proc)
End If
End Sub
Private Function Win_Proc(ByVal HWND As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
If Msg = WM_IECrashNotify Then
' Explorer has restarted, call/do something here...
End If
Win_Proc = CallWindowProc(PrevWin, HWND, Msg, wParam, lParam)
End Function