OpenWindowStationA function (winuser.h)

Opens the specified window station.


HWINSTA OpenWindowStationA(
  [in] LPCSTR      lpszWinSta,
  [in] BOOL        fInherit,
  [in] ACCESS_MASK dwDesiredAccess


[in] lpszWinSta

The name of the window station to be opened. Window station names are case-insensitive.

This window station must belong to the current session.

[in] fInherit

If this value is TRUE, processes created by this process will inherit the handle. Otherwise, the processes do not inherit this handle.

[in] dwDesiredAccess

The access to the window station. For a list of access rights, see Window Station Security and Access Rights.

Return value

If the function succeeds, the return value is the handle to the specified window station.

If the function fails, the return value is NULL. To get extended error information, call GetLastError.


After you are done with the handle, you must call CloseWindowStation to free the handle.


The winuser.h header defines OpenWindowStation as an alias which automatically selects the ANSI or Unicode version of this function based on the definition of the UNICODE preprocessor constant. Mixing usage of the encoding-neutral alias with code that not encoding-neutral can lead to mismatches that result in compilation or runtime errors. For more information, see Conventions for Function Prototypes.


Requirement Value
Minimum supported client Windows 2000 Professional [desktop apps only]
Minimum supported server Windows 2000 Server [desktop apps only]
Target Platform Windows
Header winuser.h (include Windows.h)
Library User32.lib
DLL User32.dll
API set ext-ms-win-ntuser-windowstation-ansi-l1-1-1 (introduced in Windows 10, version 10.0.14393)

See also




Window Station and Desktop Functions

Window Stations