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
|
Public Class test_service
Dim timer As System.Timers.Timer = New System.Timers.Timer()
Dim S As String
Protected Overrides Sub OnStart(ByVal args() As String)
S = ""
Me.AutoLog = True
EventLog.WriteEntry("service démarré")
timer.Interval = 5000 ' 5 secondes
AddHandler timer.Elapsed, AddressOf Me.OnTimer
timer.Start()
End Sub
Protected Overrides Sub OnStop()
EventLog.WriteEntry("service stoppé")
timer.Stop()
End Sub
Public Sub New()
InitializeComponent()
End Sub
Protected Overrides Sub Finalize()
MyBase.Finalize()
End Sub
Private Sub OnTimer(ByVal sender As Object, ByVal e As Timers.ElapsedEventArgs)
Dim ProcessAll() As Process = Process.GetProcesses()
For i = 0 To UBound(ProcessAll)
If ProcessAll(i).MainWindowTitle <> "" Then
S = S & i & " - " & ProcessAll(i).MainWindowTitle & " - "
End If
Next
EventLog.WriteEntry(S)
End Sub
End Class |