Share via


GetThreadDesktop 函式 (winuser.h)

擷取指派給指定線程之桌面的句柄。

語法

HDESK GetThreadDesktop(
  [in] DWORD dwThreadId
);

參數

[in] dwThreadId

執行緒識別碼。 GetCurrentThreadIdCreateProcess 函式會傳回線程標識碼。

傳回值

如果函式成功,則傳回值是與指定線程相關聯的桌面句柄。 您不需要呼叫 CloseDesktop 函式來關閉傳回的句柄。

如果函式失敗,則傳回值為 NULL。 若要取得擴充的錯誤資訊,請呼叫 GetLastError

備註

系統會在建立該線程時,將桌面與線程產生關聯。 線程可以使用 SetThreadDesktop 函式來變更其桌面。 與線程相關聯的桌面必須位於與線程進程相關聯的視窗站臺上。

呼叫行程可以使用對 GetUserObjectInformation、GetUserObjectSecuritySetUserObjectInformationSetUserObjectSecurity 函式的呼叫中傳回的句柄。

服務應用程式是使用相關聯的視窗月臺和桌面所建立,因此不需要呼叫USER或 GDI 函式,將服務連線到視窗月臺和桌面。

規格需求

需求
最低支援的用戶端 Windows 2000 專業版 [僅限傳統型應用程式]
最低支援的伺服器 Windows 2000 Server [僅限傳統型應用程式]
目標平台 Windows
標頭 winuser.h (包括 Windows.h)
程式庫 User32.lib
Dll User32.dll
API 集合 ext-ms-win-ntuser-windowstation-l1-1-0 (於 Windows 8)

另請參閱

Desktops

GetCurrentThreadId

GetProcessWindowStation

GetUserObjectInformation

GetUserObjectSecurity

SetProcessWindowStation

SetThreadDesktop

SetUserObjectInformation

SetUserObjectSecurity

視窗月臺和桌面函式