Using: VB.NET 2008 with Framework 2.0
Platform: WIndows 2000 SP4
Unable to find an entry point named 'WTSRegisterSessionNotific
ation' in DLL 'wtsapi32.dll'.
I need to detect when the user has locked or unlocked their workstation in order to start/stop certain procedures from being called. I have gotten the following code to work on machines running Windows XP or above, but receive the error described if the OS is Windows 2000. Unfortunately, there are still a lot of users that run Windows 2000.
This doesn't throw an error in Windows 2000, but it also doesn't work. :(
Dim SessionSwitchHandler As New SessionSwitchEventHandler(
Can someone please show me (sample code, please) how to do this on Windows 2000 using VB.NET 2005/2008?
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Me.Load
' Works in Windows XP and above but not Windows 2000
AddHandler SystemEvents.SessionSwitch, AddressOf SampleForm1_SessionSwitch
Private Sub SampleForm1_SessionSwitch(ByVal sender As System.Object, ByVal e As SessionSwitchEventArgs)
If e.Reason = SessionSwitchReason.SessionLock Then
' Computer locked
Console.WriteLine("Workstation locked at: " & Now)
ElseIf e.Reason = SessionSwitchReason.SessionUnlock Then
' Computer unlocked
Console.WriteLine("Workstation unlocked at: " & Now)