Assigns the specified desktop to the calling thread. All subsequent operations on the desktop use the access rights granted to the desktop.
Syntax
BOOL WINAPI SetThreadDesktop(
__in HDESK hDesktop
);
Parameters
- hDesktop [in]
-
A handle to the desktop to be assigned to the calling thread. This handle is returned by the
CreateDesktop,
GetThreadDesktop, OpenDesktop, or
OpenInputDesktop function.
This desktop must be associated with the current window station for the process.
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.
Remarks
The
SetThreadDesktop function will fail if the calling thread has any windows or hooks on its current desktop (unless the hDesktop parameter is a handle to the current desktop).
Warning There is a significant security risk for any service that opens a window on the interactive desktop. By opening a desktop window, a service makes itself vulnerable to attack from the logged-on user, whose application could send malicious messages to the service's desktop window and affect its ability to function.
Requirements
| Minimum supported client | Windows 2000 Professional |
| Minimum supported server | Windows 2000 Server |
| Header | Winuser.h (include Windows.h) |
| Library | User32.lib |
| DLL | User32.dll |
See Also
- CreateDesktop
- Desktops
- GetThreadDesktop
- OpenDesktop
- SetProcessWindowStation
- Window Station and Desktop Functions
Send comments about this topic to Microsoft
Build date: 11/19/2009