Hi Community,
This post is about querying for existing Window Stations in Windows. I am currently working on a project which needs to perform specific tasks depending on the Window Station, specifically when executed from a Windows Service. The code snippet is pretty straightforward as shown below
/* http://msdn.microsoft.com/en-us/library/windows/desktop/ms682643(v=vs.85).aspx */
private delegate bool EnumWindowStationProc(string lpszWindowStation, IntPtr lParam);
/* http://msdn.microsoft.com/en-us/library/windows/desktop/ms682644(v=vs.85).aspx */
[DllImport("user32.dll", SetLastError = true)]
private static extern bool EnumWindowStations(EnumWindowStationProc lpEnumFunc, IntPtr lParam);
var winsta = new List<string>();
EnumWindowStations((x, s) => {winsta.Add(x); return true;}, IntPtr.Zero);
Regards,
Angel