Bonjour,

J'ai fairt un service qui ecrit dans un journal d'evenements lorsque je demarre ou ferme Winword. (ça n'a aucun interet je sais mais c'est juste pour apprentissage...).

J'ai un problème que je n'arrive vraiment pas à comprendre :

Lorsque je fais une inscription dans un journal nommé "GLVBNET", ça marche, mais dès que je veux faire l'inscription dans un autre journal la ça marche pas...

Mon service crée bien le journal mais il n'y ecrit rien dedans.

Voici le code :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Public Class SceSessionsAppli
    Inherits System.ServiceProcess.ServiceBase
 
    Dim Processus() As Process
    Dim bEtatEnCours As Boolean = False
    Dim bEtatPrecedent As Boolean = False
    Dim el As New EventLog("GLVBNET")
 
        '
        ' Ici il y a le code automatiquement généré
        'je l'ai enlevé pour ne pas surcharger la discussion
        '
 
    Protected Overrides Sub OnStart(ByVal args() As String)
        ' Add code here to start your service. This method should set things
        ' in motion so your service can do its work.
        Timer1.Enabled = True
    End Sub
 
    Protected Overrides Sub OnStop()
        ' Add code here to perform any tear-down necessary to stop your service.
        Timer1.Enabled = False
    End Sub
 
    Private Sub Timer1_Elapsed(ByVal sender As System.Object, ByVal e As System.Timers.ElapsedEventArgs) Handles Timer1.Elapsed
        If Not EventLog.SourceExists("SessionsWord") Then
            EventLog.CreateEventSource("SessionsWord", "GLVBNET")
        End If
 
        el.Source = "SessionsWord"
 
        Processus = Process.GetProcessesByName("WinWord")
        If Processus.Length > 0 Then
            bEtatEnCours = True
            If bEtatEnCours <> bEtatPrecedent Then
                el.WriteEntry("Word Demarré", EventLogEntryType.Information)
                bEtatPrecedent = bEtatEnCours
            End If
        Else
            bEtatEnCours = False
            If bEtatEnCours <> bEtatPrecedent Then
                el.WriteEntry("Word Stoppé", EventLogEntryType.Information)
                bEtatPrecedent = bEtatEnCours
            End If
        End If
    End Sub
End Class
Si quelqu'un avait une explication ce serait sympa, car la j'ai beau chercher depuis hier...je seche!!

Merci,

X@v'