public static string[] GetDesktopNames(string winStationName)
        {
            IntPtr stationHandle = OpenWindowStation(winStationName, true, WinStationAccess.WINSTA_ENUMDESKTOPS | WinStationAccess.WINSTA_ENUMERATE);

            if (stationHandle == IntPtr.Zero)
            {
                throw new Win32ErrorCodeException("OpenWindowStation('" + winStationName + "')");
            }

            try
            {
                IList <string>       list     = new List <string>();
                EnumDesktopsDelegate callback = new EnumDesktopsDelegate((string desktopName, IntPtr lParam) => {
                    list.Add(desktopName);
                    return(true);
                });

                if (!EnumDesktops(stationHandle, callback, IntPtr.Zero))
                {
                    throw new Win32ErrorCodeException("EnumDesktops('" + winStationName + "')");
                }

                return(list.ToArray());
            }
            finally
            {
                CloseWindowStation(stationHandle);
            }
        }
예제 #2
0
        public static string[] EnumerateDesktops(string winStationName)
        {
            var winStation = OpenWindowStation(winStationName, true, 0x00020000);

            if (winStation == IntPtr.Zero)
            {
                throw new Exception("Winstation could not be opened : " + Marshal.GetLastWin32Error());
            }

            var tArrayList      = new ArrayList();
            var desktopDelegate = new EnumDesktopsDelegate(HandleDesktopEntry);

            EnumDesktops(winStation, desktopDelegate, IntPtr.Zero);

            var desktops = new string[tArrayList.Count];

            tArrayList.CopyTo(desktops);
            tArrayList.Clear();

            CloseWindowStation(winStation);

            return(desktops);
        }
예제 #3
0
 public static extern bool EnumDesktops(IntPtr hwinsta, EnumDesktopsDelegate
                                        lpEnumFunc, IntPtr lParam);
예제 #4
0
파일: Win32.cs 프로젝트: bbriggs/wesay
		public static extern bool EnumDesktops(IntPtr hwinsta, EnumDesktopsDelegate lpEnumFunc, IntPtr lParam);
예제 #5
0
 public static extern bool EnumDesktops(
     IntPtr winStation,
     EnumDesktopsDelegate EnumFunc,
     IntPtr lParam
     );
예제 #6
0
 internal static extern bool EnumDesktops(IntPtr hWinSta, EnumDesktopsDelegate lpEnumFunc, IntPtr lParam);