C# Class UlteriusServer.Api.Win32.Desktop

Encapsulates the Desktop API.
Inheritance: IDisposable, ICloneable
Show file Open project: Ulterius/server Class Usage Examples

Public Properties

Property Type Description
Default Desktop
Input Desktop

Public Methods

Method Description
Clone ( ) : object

Creates a new Desktop object with the same desktop open.

Close ( ) : bool

Closes the handle to a desktop.

Create ( string name ) : bool

Creates a new desktop. If a handle is open, it will be closed.

CreateDesktop ( string name ) : Desktop

Creates a new desktop.

CreateProcess ( string path ) : Process

Creates a new process in a desktop.

CreateProcess ( string path, string desktop ) : Process

Creates a new process on the specified desktop.

Desktop ( ) : System

Creates a new Desktop object.

Dispose ( ) : void

Dispose Object.

Dispose ( bool disposing ) : void

Dispose Object.

Exists ( string name ) : bool

Checks if the specified desktop exists (using a case sensitive search).

Exists ( string name, bool caseInsensitive ) : bool

Checks if the specified desktop exists.

GetCurrent ( ) : Desktop

Gets the desktop of the calling thread.

GetDesktopName ( Desktop desktop ) : string

Gets the name of a given desktop.

GetDesktopName ( IntPtr desktopHandle ) : string

Gets the name of a desktop from a desktop handle.

GetDesktops ( ) : string[]

Enumerates all of the desktops.

GetInputProcesses ( ) : System.Diagnostics.Process[]

Gets an array of all the processes running on the Input desktop.

GetWindows ( ) : WindowCollection

Enumerates the windows on a desktop.

Open ( string name ) : bool

Opens a desktop.

OpenDefaultDesktop ( ) : Desktop

Opens the default desktop.

OpenDesktop ( string name ) : Desktop

Opens a desktop.

OpenInput ( ) : bool

Opens the current input desktop.

OpenInputDesktop ( ) : Desktop

Opens the current input desktop.

Prepare ( ) : void

Prepares a desktop for use. For use only on newly created desktops, call straight after CreateDesktop.

SetCurrent ( Desktop desktop ) : bool

Sets the desktop of the calling thread. NOTE: Function will fail if thread has hooks or windows in the current desktop.

Show ( ) : bool

Switches input to the currently opened desktop.

Show ( string name ) : bool

Switches to the specified desktop.

ToString ( ) : string

Gets the desktop name.

Private Methods

Method Description
CheckDisposed ( ) : void
CloseDesktop ( IntPtr hDesktop ) : bool
CreateDesktop ( string lpszDesktop, IntPtr lpszDevice, IntPtr pDevmode, int dwFlags, long dwDesiredAccess, IntPtr lpsa ) : IntPtr
CreateProcess ( string lpApplicationName, string lpCommandLine, IntPtr lpProcessAttributes, IntPtr lpThreadAttributes, bool bInheritHandles, int dwCreationFlags, IntPtr lpEnvironment, string lpCurrentDirectory, STARTUPINFO &lpStartupInfo, PROCESS_INFORMATION &lpProcessInformation ) : bool
Desktop ( IntPtr desktop ) : System
DesktopProc ( string lpszDesktop, IntPtr lParam ) : bool
DesktopWindowsProc ( IntPtr wndHandle, IntPtr lParam ) : bool
EnumDesktopWindows ( IntPtr hDesktop, EnumDesktopWindowsProc lpfn, IntPtr lParam ) : bool
EnumDesktops ( IntPtr hwinsta, EnumDesktopProc lpEnumFunc, IntPtr lParam ) : bool
GetCurrentThreadId ( ) : int
GetProcessId ( IntPtr process ) : int
GetProcessWindowStation ( ) : IntPtr
GetThreadDesktop ( int dwThreadId ) : IntPtr
GetThreadId ( IntPtr thread ) : int
GetUserObjectInformation ( IntPtr hObj, int nIndex, IntPtr pvInfo, int nLength, int &lpnLengthNeeded ) : bool
GetWindowText ( IntPtr hWnd, IntPtr lpString, int nMaxCount ) : int
OpenDesktop ( string lpszDesktop, int dwFlags, bool fInherit, long dwDesiredAccess ) : IntPtr
OpenInputDesktop ( int dwFlags, bool fInherit, long dwDesiredAccess ) : IntPtr
SetThreadDesktop ( IntPtr hDesktop ) : bool
SwitchDesktop ( IntPtr hDesktop ) : bool
WTSGetActiveConsoleSessionId ( ) : int

Method Details

Clone() public method

Creates a new Desktop object with the same desktop open.
public Clone ( ) : object
return object

Close() public method

Closes the handle to a desktop.
public Close ( ) : bool
return bool

Create() public method

Creates a new desktop. If a handle is open, it will be closed.
public Create ( string name ) : bool
name string The name of the new desktop. Must be unique, and is case sensitive.
return bool

CreateDesktop() public static method

Creates a new desktop.
public static CreateDesktop ( string name ) : Desktop
name string The name of the desktop to create. Names are case sensitive.
return Desktop

CreateProcess() public method

Creates a new process in a desktop.
public CreateProcess ( string path ) : Process
path string Path to application.
return System.Diagnostics.Process

CreateProcess() public static method

Creates a new process on the specified desktop.
public static CreateProcess ( string path, string desktop ) : Process
path string Path to application.
desktop string Desktop name.
return System.Diagnostics.Process

Desktop() public method

Creates a new Desktop object.
public Desktop ( ) : System
return System

Dispose() public method

Dispose Object.
public Dispose ( ) : void
return void

Dispose() public method

Dispose Object.
public Dispose ( bool disposing ) : void
disposing bool True to dispose managed resources.
return void

Exists() public static method

Checks if the specified desktop exists (using a case sensitive search).
public static Exists ( string name ) : bool
name string The name of the desktop.
return bool

Exists() public static method

Checks if the specified desktop exists.
public static Exists ( string name, bool caseInsensitive ) : bool
name string The name of the desktop.
caseInsensitive bool If the search is case INsensitive.
return bool

GetCurrent() public static method

Gets the desktop of the calling thread.
public static GetCurrent ( ) : Desktop
return Desktop

GetDesktopName() public static method

Gets the name of a given desktop.
public static GetDesktopName ( Desktop desktop ) : string
desktop Desktop Desktop object whos name is to be found.
return string

GetDesktopName() public static method

Gets the name of a desktop from a desktop handle.
public static GetDesktopName ( IntPtr desktopHandle ) : string
desktopHandle System.IntPtr
return string

GetDesktops() public static method

Enumerates all of the desktops.
public static GetDesktops ( ) : string[]
return string[]

GetInputProcesses() public static method

Gets an array of all the processes running on the Input desktop.
public static GetInputProcesses ( ) : System.Diagnostics.Process[]
return System.Diagnostics.Process[]

GetWindows() public method

Enumerates the windows on a desktop.
public GetWindows ( ) : WindowCollection
return WindowCollection

Open() public method

Opens a desktop.
public Open ( string name ) : bool
name string The name of the desktop to open.
return bool

OpenDefaultDesktop() public static method

Opens the default desktop.
public static OpenDefaultDesktop ( ) : Desktop
return Desktop

OpenDesktop() public static method

Opens a desktop.
public static OpenDesktop ( string name ) : Desktop
name string The name of the desktop to open.
return Desktop

OpenInput() public method

Opens the current input desktop.
public OpenInput ( ) : bool
return bool

OpenInputDesktop() public static method

Opens the current input desktop.
public static OpenInputDesktop ( ) : Desktop
return Desktop

Prepare() public method

Prepares a desktop for use. For use only on newly created desktops, call straight after CreateDesktop.
public Prepare ( ) : void
return void

SetCurrent() public static method

Sets the desktop of the calling thread. NOTE: Function will fail if thread has hooks or windows in the current desktop.
public static SetCurrent ( Desktop desktop ) : bool
desktop Desktop Desktop to put the thread in.
return bool

Show() public method

Switches input to the currently opened desktop.
public Show ( ) : bool
return bool

Show() public static method

Switches to the specified desktop.
public static Show ( string name ) : bool
name string Name of desktop to switch input to.
return bool

ToString() public method

Gets the desktop name.
public ToString ( ) : string
return string

Property Details

Default public static property

Opens the default desktop.
public static Desktop,UlteriusServer.Api.Win32 Default
return Desktop

Input public static property

Opens the desktop the user if viewing.
public static Desktop,UlteriusServer.Api.Win32 Input
return Desktop