ReactOS 0.4.15-dev-7953-g1f49173
CDesktopThread Class Reference
Collaboration diagram for CDesktopThread:

Public Member Functions

 CDesktopThread ()
 
 ~CDesktopThread ()
 
HRESULT Initialize (ITrayWindow *pTray)
 
void Destroy ()
 

Private Member Functions

DWORD DesktopThreadProc ()
 

Static Private Member Functions

static DWORD WINAPI s_DesktopThreadProc (LPVOID lpParameter)
 

Private Attributes

CComPtr< ITrayWindow > m_Tray
 
HANDLE m_hInitEvent
 
HANDLE m_hThread
 
DWORD m_ThreadId
 

Detailed Description

Definition at line 23 of file desktop.cpp.

Constructor & Destructor Documentation

◆ CDesktopThread()

CDesktopThread::CDesktopThread ( )

Definition at line 44 of file desktop.cpp.

44 :
45 m_Tray(NULL),
48 m_ThreadId(0)
49{
50}
HANDLE m_hInitEvent
Definition: desktop.cpp:27
DWORD m_ThreadId
Definition: desktop.cpp:29
CComPtr< ITrayWindow > m_Tray
Definition: desktop.cpp:26
HANDLE m_hThread
Definition: desktop.cpp:28
#define NULL
Definition: types.h:112

◆ ~CDesktopThread()

CDesktopThread::~CDesktopThread ( )

Definition at line 52 of file desktop.cpp.

53{
54 Destroy();
55}
void Destroy()
Definition: desktop.cpp:117

Member Function Documentation

◆ DesktopThreadProc()

DWORD CDesktopThread::DesktopThreadProc ( )
private

Definition at line 143 of file desktop.cpp.

144{
146 HANDLE hDesktop;
147 HRESULT hRet;
148 DWORD dwResult = 1;
149
151
152 hRet = m_Tray->QueryInterface(IID_PPV_ARG(IShellDesktopTray, &pSdt));
153 if (!SUCCEEDED(hRet))
154 {
155 goto Cleanup;
156 }
157
158 hDesktop = _SHCreateDesktop(pSdt);
159 if (!hDesktop)
160 {
161 goto Cleanup;
162 }
163
165 {
166 /* Failed to notify that we initialized successfully, kill ourselves
167 * to make the main thread wake up! */
168 goto Cleanup;
169 }
170
171 _SHDesktopMessageLoop(hDesktop);
172 dwResult = 0;
173
174Cleanup:
176 return dwResult;
177}
BOOL WINAPI _SHDesktopMessageLoop(HANDLE hDesktop)
Definition: rshell.cpp:81
HANDLE WINAPI _SHCreateDesktop(IShellDesktopTray *ShellDesk)
Definition: rshell.cpp:52
HRESULT WINAPI DECLSPEC_HOTPATCH OleInitialize(LPVOID reserved)
Definition: ole2.c:169
void WINAPI DECLSPEC_HOTPATCH OleUninitialize(void)
Definition: ole2.c:230
static const WCHAR Cleanup[]
Definition: register.c:80
unsigned long DWORD
Definition: ntddk_ex.h:95
#define SUCCEEDED(hr)
Definition: intsafe.h:50
BOOL WINAPI DECLSPEC_HOTPATCH SetEvent(IN HANDLE hEvent)
Definition: synch.c:733
#define IID_PPV_ARG(Itype, ppType)

Referenced by s_DesktopThreadProc().

◆ Destroy()

void CDesktopThread::Destroy ( )

Definition at line 117 of file desktop.cpp.

118{
119 if (m_hThread)
120 {
121 DWORD WaitResult = WaitForSingleObject(m_hThread, 0);
122 if (WaitResult == WAIT_TIMEOUT)
123 {
124 /* Send WM_QUIT message to the thread and wait for it to terminate */
127 }
128
130 m_hThread = NULL;
131 m_ThreadId = 0;
132 }
133
134 if (m_hInitEvent)
135 {
138 }
139
140 m_Tray = NULL;
141}
#define WAIT_TIMEOUT
Definition: dderror.h:14
#define CloseHandle
Definition: compat.h:739
#define INFINITE
Definition: serial.h:102
DWORD WINAPI WaitForSingleObject(IN HANDLE hHandle, IN DWORD dwMilliseconds)
Definition: synch.c:82
#define WM_QUIT
Definition: winuser.h:1623
BOOL WINAPI PostThreadMessageW(_In_ DWORD, _In_ UINT, _In_ WPARAM, _In_ LPARAM)

Referenced by ~CDesktopThread().

◆ Initialize()

HRESULT CDesktopThread::Initialize ( ITrayWindow *  pTray)

Definition at line 57 of file desktop.cpp.

58{
59 HANDLE Handles[2];
60
61 if (!pTray || m_Tray)
62 {
63 return E_FAIL;
64 }
65
67 if (!m_hInitEvent)
68 {
69 return E_FAIL;
70 }
71
72 m_Tray = pTray;
74
75 if (!m_hThread)
76 {
79
80 m_Tray = NULL;
81
82 return E_FAIL;
83 }
84
85 Handles[0] = m_hThread;
86 Handles[1] = m_hInitEvent;
87
88 for (;;)
89 {
90 DWORD WaitResult = MsgWaitForMultipleObjects(_countof(Handles), Handles, FALSE, INFINITE, QS_ALLEVENTS);
91
92 if (WaitResult == WAIT_OBJECT_0 + _countof(Handles))
93 {
95 }
96 else if (WaitResult != WAIT_FAILED && WaitResult != WAIT_OBJECT_0)
97 {
98 break;
99 }
100 else
101 {
103 m_hThread = NULL;
104 m_ThreadId = 0;
105
108
109 m_Tray = NULL;
110
111 return E_FAIL;
112 }
113 }
114 return S_OK;
115}
VOID TrayProcessMessages(IN OUT ITrayWindow *Tray)
static DWORD WINAPI s_DesktopThreadProc(LPVOID lpParameter)
Definition: desktop.cpp:179
#define E_FAIL
Definition: ddrawi.h:102
#define FALSE
Definition: types.h:117
HANDLE WINAPI DECLSPEC_HOTPATCH CreateThread(IN LPSECURITY_ATTRIBUTES lpThreadAttributes, IN DWORD dwStackSize, IN LPTHREAD_START_ROUTINE lpStartAddress, IN LPVOID lpParameter, IN DWORD dwCreationFlags, OUT LPDWORD lpThreadId)
Definition: thread.c:137
#define S_OK
Definition: intsafe.h:52
#define _countof(array)
Definition: sndvol32.h:68
HANDLE WINAPI DECLSPEC_HOTPATCH CreateEventW(IN LPSECURITY_ATTRIBUTES lpEventAttributes OPTIONAL, IN BOOL bManualReset, IN BOOL bInitialState, IN LPCWSTR lpName OPTIONAL)
Definition: synch.c:651
#define WAIT_OBJECT_0
Definition: winbase.h:406
#define WAIT_FAILED
Definition: winbase.h:413
#define QS_ALLEVENTS
Definition: winuser.h:902
DWORD WINAPI MsgWaitForMultipleObjects(_In_ DWORD nCount, _In_reads_opt_(nCount) CONST HANDLE *pHandles, _In_ BOOL fWaitAll, _In_ DWORD dwMilliseconds, _In_ DWORD dwWakeMask)

Referenced by DesktopCreateWindow().

◆ s_DesktopThreadProc()

DWORD WINAPI CDesktopThread::s_DesktopThreadProc ( LPVOID  lpParameter)
staticprivate

Definition at line 179 of file desktop.cpp.

180{
181 CDesktopThread* pDesktopThread = static_cast<CDesktopThread*>(lpParameter);
182 return pDesktopThread->DesktopThreadProc();
183}
DWORD DesktopThreadProc()
Definition: desktop.cpp:143

Referenced by Initialize().

Member Data Documentation

◆ m_hInitEvent

HANDLE CDesktopThread::m_hInitEvent
private

Definition at line 27 of file desktop.cpp.

Referenced by DesktopThreadProc(), Destroy(), and Initialize().

◆ m_hThread

HANDLE CDesktopThread::m_hThread
private

Definition at line 28 of file desktop.cpp.

Referenced by Destroy(), and Initialize().

◆ m_ThreadId

DWORD CDesktopThread::m_ThreadId
private

Definition at line 29 of file desktop.cpp.

Referenced by Destroy(), and Initialize().

◆ m_Tray

CComPtr<ITrayWindow> CDesktopThread::m_Tray
private

Definition at line 26 of file desktop.cpp.

Referenced by DesktopThreadProc(), Destroy(), and Initialize().


The documentation for this class was generated from the following file: