Home | Info | Community | Development | myReactOS | Contact Us
ReactOS Development > Doxygendesktop.c
Go to the documentation of this file.
00001 /* 00002 * ReactOS Explorer 00003 * 00004 * Copyright 2006 - 2007 Thomas Weidenmueller <w3seek@reactos.org> 00005 * 00006 * This library is free software; you can redistribute it and/or 00007 * modify it under the terms of the GNU Lesser General Public 00008 * License as published by the Free Software Foundation; either 00009 * version 2.1 of the License, or (at your option) any later version. 00010 * 00011 * This library is distributed in the hope that it will be useful, 00012 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * Lesser General Public License for more details. 00015 * 00016 * You should have received a copy of the GNU Lesser General Public 00017 * License along with this library; if not, write to the Free Software 00018 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00019 */ 00020 00021 #include <precomp.h> 00022 00023 typedef struct _DESKCREATEINFO 00024 { 00025 HANDLE hEvent; 00026 ITrayWindow *Tray; 00027 HANDLE hDesktop; 00028 } DESKCREATEINFO, *PDESKCREATEINFO; 00029 00030 static DWORD CALLBACK 00031 DesktopThreadProc(IN OUT LPVOID lpParameter) 00032 { 00033 volatile DESKCREATEINFO *DeskCreateInfo = (volatile DESKCREATEINFO *)lpParameter; 00034 IShellDesktopTray *pSdt; 00035 HANDLE hDesktop; 00036 HRESULT hRet; 00037 00038 OleInitialize(NULL); 00039 00040 hRet = ITrayWindow_QueryInterface(DeskCreateInfo->Tray, 00041 &IID_IShellDesktopTray, 00042 (PVOID*)&pSdt); 00043 if (!SUCCEEDED(hRet)) 00044 return 1; 00045 00046 hDesktop = SHCreateDesktop(pSdt); 00047 00048 IShellDesktopTray_Release(pSdt); 00049 if (hDesktop == NULL) 00050 return 1; 00051 00052 (void)InterlockedExchangePointer(&DeskCreateInfo->hDesktop, 00053 hDesktop); 00054 00055 if (!SetEvent(DeskCreateInfo->hEvent)) 00056 { 00057 /* Failed to notify that we initialized successfully, kill ourselves 00058 to make the main thread wake up! */ 00059 return 1; 00060 } 00061 00062 SHDesktopMessageLoop(hDesktop); 00063 00064 /* FIXME: Properly rundown the main thread! */ 00065 ExitProcess(0); 00066 00067 return 0; 00068 } 00069 00070 HANDLE 00071 DesktopCreateWindow(IN OUT ITrayWindow *Tray) 00072 { 00073 HANDLE hThread; 00074 HANDLE hEvent; 00075 DWORD DesktopThreadId; 00076 HANDLE hDesktop = NULL; 00077 HANDLE Handles[2]; 00078 DWORD WaitResult; 00079 00080 hEvent = CreateEvent(NULL, 00081 FALSE, 00082 FALSE, 00083 NULL); 00084 if (hEvent != NULL) 00085 { 00086 volatile DESKCREATEINFO DeskCreateInfo; 00087 00088 DeskCreateInfo.hEvent = hEvent; 00089 DeskCreateInfo.Tray = Tray; 00090 DeskCreateInfo.hDesktop = NULL; 00091 00092 hThread = CreateThread(NULL, 00093 0, 00094 DesktopThreadProc, 00095 (PVOID)&DeskCreateInfo, 00096 0, 00097 &DesktopThreadId); 00098 if (hThread != NULL) 00099 { 00100 Handles[0] = hThread; 00101 Handles[1] = hEvent; 00102 00103 for (;;) 00104 { 00105 WaitResult = MsgWaitForMultipleObjects(sizeof(Handles) / sizeof(Handles[0]), 00106 Handles, 00107 FALSE, 00108 INFINITE, 00109 QS_ALLEVENTS); 00110 if (WaitResult == WAIT_OBJECT_0 + (sizeof(Handles) / sizeof(Handles[0]))) 00111 TrayProcessMessages(Tray); 00112 else if (WaitResult != WAIT_FAILED && WaitResult != WAIT_OBJECT_0) 00113 { 00114 hDesktop = DeskCreateInfo.hDesktop; 00115 break; 00116 } 00117 } 00118 00119 CloseHandle(hThread); 00120 } 00121 00122 CloseHandle(hEvent); 00123 } 00124 00125 return hDesktop; 00126 } 00127 00128 VOID 00129 DesktopDestroyShellWindow(IN HANDLE hDesktop) 00130 { 00131 return; 00132 } Generated on Mon May 28 2012 04:18:06 for ReactOS by
1.7.6.1
|