CloseWindowStation function (winuser.h)

Closes an open window station handle.


BOOL CloseWindowStation(
  [in] HWINSTA hWinSta


[in] hWinSta

A handle to the window station to be closed. This handle is returned by the CreateWindowStation or OpenWindowStation function. Do not specify the handle returned by the GetProcessWindowStation function.

Return value

If the function succeeds, the return value is nonzero.

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

Windows Server 2003 and Windows XP/2000:  This function does not set the last error code on failure.


The CloseWindowStation function will fail if the handle being closed is for the window station assigned to the calling process.


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-l1-1-0 (introduced in Windows 8)

See also

Window Station and Desktop Functions

Window Stations