CreateWindowStation function
Applies to: desktop apps only
Creates a window station object, associates it with the calling process, and assigns it to the current session.
Syntax
HWINSTA WINAPI CreateWindowStation( __in_opt LPCTSTR lpwinsta, DWORD dwFlags, __in ACCESS_MASK dwDesiredAccess, __in_opt LPSECURITY_ATTRIBUTES lpsa );
Parameters
- lpwinsta [in, optional]
-
The name of the window station to be created. Window station names are case-insensitive and cannot contain backslash characters (\). Only members of the Administrators group are allowed to specify a name. If lpwinsta is NULL or an empty string, the system forms a window station name using the logon session identifier for the calling process. To get this name, call the GetUserObjectInformation function.
- dwFlags
-
If this parameter is CWF_CREATE_ONLY and the window station already exists, the call fails. If this flag is not specified and the window station already exists, the function succeeds and returns a new handle to the existing window station.
Windows XP/2000: This parameter is reserved and must be zero. - dwDesiredAccess [in]
-
The type of access the returned handle has to the window station. In addition, you can specify any of the standard access rights, such as READ_CONTROL or WRITE_DAC, and a combination of the window station-specific access rights. For more information, see Window Station Security and Access Rights.
- lpsa [in, optional]
-
A pointer to a SECURITY_ATTRIBUTES structure that determines whether the returned handle can be inherited by child processes. If lpsa is NULL, the handle cannot be inherited.
The lpSecurityDescriptor member of the structure specifies a security descriptor for the new window station. If lpsa is NULL, the window station (and any desktops created within the window) gets a security descriptor that grants GENERIC_ALL access to all users.
Return value
If the function succeeds, the return value is a handle to the newly created window station. If the specified window station already exists, the function succeeds and returns a handle to the existing window station.
If the function fails, the return value is NULL. To get extended error information, call GetLastError.
Remarks
After you are done with the handle, you must call CloseWindowStation to free the handle.
Requirements
|
Minimum supported client | Windows 2000 Professional |
|---|---|
|
Minimum supported server | Windows 2000 Server |
|
Header |
|
|
Library |
|
|
DLL |
|
|
Unicode and ANSI names | CreateWindowStationW (Unicode) and CreateWindowStationA (ANSI) |
See also
- CloseWindowStation
- GetUserObjectInformation
- OpenWindowStation
- Window Station and Desktop Functions
- Window Stations
Send comments about this topic to Microsoft
Build date: 2/3/2012
After doing a little research this info cleared things up quite a bit for me:
WinSta0 is the only window station that can receive user input. You can create other Window Stations, and create desktops on them, but you cannot set them as the InputDesktop. You can also only have one InputDesktop at a time per WinSta0. Other desktops cannot use the display.
Also you would expect that when you remote desktop there is e.g. WinSta1, however, if you read the above you realize that's impossible, it must ALSO be a WinSta0 in order for it to allow user input. Therefore WinSta0 is actually a per-user-session thing.
- 4/26/2010
- Tim Lovell-Smith