GarthJL1965 / cassia

Automatically exported from code.google.com/p/cassia
0 stars 0 forks source link

Add support for session change notifications #2

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
WTSRegisterSessionNotification(Ex)

Original issue reported on code.google.com by danports on 10 May 2009 at 1:34

GoogleCodeExporter commented 8 years ago
You can already receive session change notifications in services (via 
ServiceBase.OnSessionChange), which is where notifications are usually most 
useful, so I don't think this is a high priority.

Original comment by danports on 8 May 2011 at 12:39

GoogleCodeExporter commented 8 years ago
Issue 47 has been merged into this issue.

Original comment by danports on 12 Feb 2012 at 12:00

GoogleCodeExporter commented 8 years ago
WTSRegisterSessionNotificationEx (which allows monitoring of remote RD servers) 
requires Vista/2008. On older platforms, it may be possible to work around this 
using an undocumented function in winsta.dll, but I wouldn't count on that 
being easy to implement.

Original comment by danports on 15 Feb 2012 at 3:53

GoogleCodeExporter commented 8 years ago
WTSWaitSystemEvent is another option, but the function is riddled with bugs -- 
sometimes notifications are dispatched twice, sometimes the WTS_EVENT_FLUSH 
value doesn't work. But it's a possibility for supporting remote XP/2003 
session notifications.

See:
- http://msdn.microsoft.com/en-us/library/windows/desktop/aa383856(v=vs.85).aspx
- http://www.remkoweijnen.nl/blog/2008/01/25/using-wtswaitsystemevent/

Original comment by danports on 15 Feb 2012 at 4:06

GoogleCodeExporter commented 8 years ago

Original comment by danports on 15 Feb 2012 at 4:28

GoogleCodeExporter commented 8 years ago
Use the same technique the Microsoft.Win32.SystemEvents class uses to create a 
hidden window to receive the relevant messages. WTSWaitSystemEvent doesn't 
provide as much information as WTSRegisterSessionNotificationEx. We could 
support WTSRegisterSessionNotification for local notifications on XP/2003, but 
it's probably not worth supporting notifications for remote systems on those 
platforms (unless we can dig up the relevant internal API easily -- XP/2003 are 
in the extended support phase already). There's 
WinStationRegisterNotificationEvent in winsta.dll, but it's not clear how that 
works without doing some spelunking.

Original comment by danports on 26 Feb 2012 at 2:45

GoogleCodeExporter commented 8 years ago
hey there,
if you use a Windows Service you can easily receive session changes:
just override the OnSessionChange method and set CanHandleSessionChangeEvent to 
true.
This method is fairly spare documented although it works.

Original comment by christop...@gmail.com on 13 Sep 2012 at 2:03

GoogleCodeExporter commented 8 years ago
Thanks for the comment. I actually use the OnSessionChange method in one of my 
projects and noted it in the first comment -- this improvement would be for 
non-service applications that want to receive session change notifications 
(e.g. a RD Services Manager type app).

Original comment by danports on 14 Sep 2012 at 2:42

GoogleCodeExporter commented 8 years ago
Issue 77 has been merged into this issue.

Original comment by danports on 23 Jan 2015 at 11:55