UlteriusServer.Api.Win32.Desktop.GetDesktops C# (CSharp) Method

GetDesktops() public static method

Enumerates all of the desktops.
public static GetDesktops ( ) : string[]
return string[]
        public static string[] GetDesktops()
        {
            // attempt to enum desktops.
            var windowStation = GetProcessWindowStation();

            // check we got a valid handle.
            if (windowStation == IntPtr.Zero) return new string[0];

            string[] desktops;

            // lock the object. thread safety and all.
            lock (m_sc = new StringCollection())
            {
                var result = EnumDesktops(windowStation, DesktopProc, IntPtr.Zero);

                // something went wrong.
                if (!result) return new string[0];

                //	// turn the collection into an array.
                desktops = new string[m_sc.Count];
                for (var i = 0; i < desktops.Length; i++) desktops[i] = m_sc[i];
            }

            return desktops;
        }