Export (0) Print
Expand All

GetThreadDesktop function

Retrieves a handle to the desktop assigned to the specified thread.

Syntax


HDESK WINAPI GetThreadDesktop(
  _In_  DWORD dwThreadId
);

Parameters

dwThreadId [in]

The thread identifier. The GetCurrentThreadId and CreateProcess functions return thread identifiers.

Return value

If the function succeeds, the return value is a handle to the desktop associated with the specified thread. You do not need to call the CloseDesktop function to close the returned handle.

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

Remarks

The system associates a desktop with a thread when that thread is created. A thread can use the SetThreadDesktop function to change its desktop. The desktop associated with a thread must be on the window station associated with the thread's process.

The calling process can use the returned handle in calls to the GetUserObjectInformation, GetUserObjectSecurity, SetUserObjectInformation, and SetUserObjectSecurity functions.

A service application is created with an associated window station and desktop, so there is no need to call a USER or GDI function to connect the service to a window station and desktop.

Requirements

Minimum supported client

Windows 2000 Professional [desktop apps only]

Minimum supported server

Windows 2000 Server [desktop apps only]

Header

Winuser.h (include Windows.h)

Library

User32.lib

DLL

User32.dll

See also

Desktops
GetCurrentThreadId
GetProcessWindowStation
GetUserObjectInformation
GetUserObjectSecurity
SetProcessWindowStation
SetThreadDesktop
SetUserObjectInformation
SetUserObjectSecurity
Window Station and Desktop Functions

 

 

Community Additions

ADD
Show:
© 2014 Microsoft