Multiple desktop support in Windows

In my previous job I worked in the development team of Adobe FrameMaker. This product shipped on Sun Solaris, Windows and Mac. I worked parallely on a Windows box, a Sun Blade system and a PowerMac G5. So I got used to the best of all of them.

Solaris (and many other window managers) supports multiple desktops for each user and easy swtiching between them. I got used to have 4 desktops and spread my applications across them. One had all the coding stuff like the editors and debuggers and the other had email-client and browser and so on. I always felt unhappy that Windows didn't support this. It was much later when I came across the multi-desktop Win32 API's. After playing around a bit with them I was really surprised that Windows (XP/2000/2003) didn't expose this feature directly. Later I found Microsoft Power Toys for XP which supported multi-desktops. I assumed that Vista Window Manager will have this directly. But unfortunately it does not (see the feature list here). 

Using the Windows Desktop API's its extremely easy to create multiple desktops and switch between them. The following code creates a new desktop name MyDesk and launches Windows explorer on it and switches to the newly created desktop

 IntPtr hDesk = Native.CreateDesktop("MyDesk", IntPtr.Zero,                  IntPtr.Zero, 0, AccessRights, IntPtr.Zero);
STARTUPINFO si = new STARTUPINFO();
si.cb = Marshal.SizeOf(si);
si.lpDesktop =   "MyDesk"  ; 
PROCESS_INFORMATION pi = new PROCESS_INFORMATION();
bool result = Native.CreateProcess(null, @"C:\WINDOWS\explorer.exe", 
                            IntPtr.Zero, IntPtr.Zero,
                            true, NORMAL_PRIORITY_CLASS,
                            IntPtr.Zero, null, ref si, ref pi);Native.SwitchDesktop(hDesk);

Check out https://www.pinvoke.net for the C# signatures for these Win32 api's. Similarly is easy to enumerate all the desktops

 delegate bool EnumDesktopsDelegate(string desktop, IntPtr lParam);

private bool DesktopEnum(string desktop, IntPtr lParam)
{
    Console.WriteLine(desktop);
    return true;
}
Native.EnumDesktops(windowStation, 
            new EnumDesktopsDelegate(DesktopEnum), 
            IntPtr.Zero);