1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75
|
Public Class Form1
Dim hdle_mui As New List(Of String)
Dim title_mui As New List(Of String)
Public Declare Function GetWindowRect Lib "user32.dll" (ByVal hWnd As IntPtr, ByRef lpRect As Rectangle) As Boolean
'démarrer ou arrêter la surveillance
Private Sub BT_start_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_start.Click
If Timer_fen_mui.Enabled Then
Timer_fen_mui.Stop()
BT_start.Text = "Démarre surveillance"
Else
Timer_fen_mui.Start()
BT_start.Text = "Arrête surveillance"
End If
End Sub
'surveillance des applications Modern UI sur le bureau
Private Sub Timer_fen_mui_Tick(ByVal sender As Object, ByVal e As System.EventArgs) Handles Timer_fen_mui.Tick
Dim p() As Process = Process.GetProcessesByName("ApplicationFrameHost")
If p.Length > 0 Then
Dim hdle As String = p(0).MainWindowHandle.ToString
Dim title As String = p(0).MainWindowTitle
If hdle <> "0" Then
If hdle_mui.Count > 0 Then
If Not hdle_mui.Contains(hdle) Then
hdle_mui.Add(hdle)
title_mui.Add(title)
LB_result.Items.Add("Nouveau Handle ajouté: " & hdle & " : " & title)
End If
Else
hdle_mui.Add(hdle)
title_mui.Add(title)
LB_result.Items.Add("Nouveau Handle ajouté: " & hdle & " : " & title)
End If
End If
End If
Dim rect As New Rectangle
For n = hdle_mui.Count - 1 To 0 Step -1
If GetWindowRect(Convert.ToInt64(hdle_mui(n)), rect) = False Then
LB_result.Items.Add("handle supprimé: " & hdle_mui(n) & " : " & title_mui(n))
hdle_mui.RemoveAt(n)
title_mui.RemoveAt(n)
End If
Next
End Sub
'tuer le processus ApplicationFrameHost si lancé
Private Sub BT_kill_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_kill.Click
Dim p() As Process = Process.GetProcessesByName("ApplicationFrameHost")
If p.Length > 0 Then
p(0).Kill()
End If
End Sub
'nettoyer la listbox
Private Sub BT_clear_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BT_clear.Click
LB_result.Items.Clear()
For n = 0 To hdle_mui.Count - 1
LB_result.Items.Add("handle mémorisé: " & hdle_mui(n) & " : " & title_mui(n))
Next
End Sub
'fermeture
Private Sub Form1_FormClosing(ByVal sender As Object, ByVal e As System.Windows.Forms.FormClosingEventArgs) Handles Me.FormClosing
Timer_fen_mui.Stop()
End Sub
'ouverture : lancer le timer de surveillance
Private Sub Form1_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Timer_fen_mui.Start()
End Sub
End Class |
Partager