Group: Window Station and Desktop - Library: user32
Obtaining a handle to the desktop associated with the calling thread
How to prevent users from accessing the Windows Desktop and from switching to other applications
HDESK GetThreadDesktop(
DWORD dwThreadId // thread identifier
);
DECLARE INTEGER GetThreadDesktop IN user32;
INTEGER dwThreadId
dwThreadId [in] Handle to the thread for which to return the desktop handle. The GetCurrentThreadId and CreateProcess functions return thread identifiers.
If the function succeeds, the return value is a handle to the desktop associated with the specified thread.
Windows 95/98/Me: The system does not support multiple desktops, so GetThreadDesktop always returns the same value.