• [DllImport("user32.dll")]
    public static extern IntPtr CreateDesktop(string lpszDesktop, IntPtr lpszDevice, IntPtr pDevmode, int dwFlags, uint dwDesiredAccess, IntPtr lpsa);
    
  • SwitchDesktop() - for switching between the original and the new desktop


  • [DllImport("user32.dll")]
    private static extern bool SwitchDesktop(IntPtr hDesktop);
    
  • CloseDesktop() - closes the desktop handle


  • [DllImport("user32.dll")]
    public static extern bool CloseDesktop(IntPtr handle);
    
  • SetThreadDesktop() - sets the desktop for the calling thread


  • [DllImport("user32.dll")]
    public static extern bool SetThreadDesktop(IntPtr hDesktop);
    
  • GetThreadDesktop - gets the desktop defined for the specified thread


  • [DllImport("user32.dll")]
    public static extern IntPtr GetThreadDesktop(int dwThreadId);
    
  • GetCurrentThreadId() - gets the current thread’s id