Skip to content

Commit 663856b

Browse files
committed
Added missing WndProc function lost during cleanup
Added back the WndProc function accidentally dropped during cleanup in commit @d72e59c Without this function system lock/unlock events would NOT be logged.
1 parent 5c05aaa commit 663856b

File tree

1 file changed

+43
-0
lines changed

1 file changed

+43
-0
lines changed

ActiveWindowLogger/frmMain.vb

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,49 @@ Public Class frmMain
3434
WTSUnRegisterSessionNotification(Me.Handle)
3535
End Sub
3636

37+
Protected Overrides Sub WndProc(ByRef m As System.Windows.Forms.Message)
38+
Dim newEntry As ListViewItem
39+
40+
Select Case m.Msg
41+
Case WM_WTSSESSION_CHANGE
42+
Select Case m.WParam.ToInt32
43+
Case WTS.CONSOLE_CONNECT
44+
'Debug.Print("A session was connected to the console session.")
45+
Case WTS.CONSOLE_DISCONNECT
46+
'Debug.Print("A session was disconnected from the console session.")
47+
Case WTS.REMOTE_CONNECT
48+
'Debug.Print("A session was connected to the remote session.")
49+
Case WTS.REMOTE_DISCONNECT
50+
'Debug.Print("A session was disconnected from the remote session.")
51+
Case WTS.SESSION_LOGON
52+
'Debug.Print("A user has logged on to the session.")
53+
Case WTS.SESSION_LOGOFF
54+
'Debug.Print("A user has logged off the session.")
55+
Case WTS.SESSION_LOCK
56+
'Debug.Print("A session has been locked.")
57+
' Populate the listview with Windows locked entry
58+
newEntry = lvEntries.Items.Insert(0, "-1")
59+
newEntry.SubItems.Add("Microsoft")
60+
newEntry.SubItems.Add("Windows")
61+
newEntry.SubItems.Add("Locked")
62+
newEntry.SubItems.Add(Format(Now, "yyyy/MM/dd HH:mm:ss"))
63+
Case WTS.SESSION_UNLOCK
64+
'Debug.Print("A session has been unlocked.")
65+
' Populate the listview with Windows locked entry
66+
newEntry = lvEntries.Items.Insert(0, "-1")
67+
newEntry.SubItems.Add("Microsoft")
68+
newEntry.SubItems.Add("Windows")
69+
newEntry.SubItems.Add("Unlocked")
70+
newEntry.SubItems.Add(Format(Now, "yyyy/MM/dd HH:mm:ss"))
71+
Case WTS.SESSION_REMOTE_CONTROL
72+
'Debug.Print("A session has changed its remote controlled status. To determine the status, call GetSystemMetrics and check the SM_REMOTECONTROL metric.")
73+
End Select
74+
End Select
75+
76+
MyBase.WndProc(m)
77+
78+
End Sub
79+
3780
Private Sub lvEntries_ItemChecked(ByVal sender As Object, ByVal e As System.Windows.Forms.ItemCheckedEventArgs) Handles lvEntries.ItemChecked
3881
If (lvEntries.Items.Count <> lvEntries.CheckedItems.Count) And (lvEntries.CheckedItems.Count > 0) Then
3982
chkSelect.CheckState = CheckState.Indeterminate

0 commit comments

Comments
 (0)