desktop.c 69 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694169516961697169816991700170117021703170417051706170717081709171017111712171317141715171617171718171917201721172217231724172517261727172817291730173117321733173417351736173717381739174017411742174317441745174617471748174917501751175217531754175517561757175817591760176117621763176417651766176717681769177017711772177317741775177617771778177917801781178217831784178517861787178817891790179117921793179417951796179717981799180018011802180318041805180618071808180918101811181218131814181518161817181818191820182118221823182418251826182718281829183018311832183318341835183618371838183918401841184218431844184518461847184818491850185118521853185418551856185718581859186018611862186318641865186618671868186918701871187218731874187518761877187818791880188118821883188418851886188718881889189018911892189318941895189618971898189919001901190219031904190519061907190819091910191119121913191419151916191719181919192019211922192319241925192619271928192919301931193219331934193519361937193819391940194119421943194419451946194719481949195019511952195319541955195619571958195919601961196219631964196519661967196819691970197119721973197419751976197719781979198019811982198319841985198619871988198919901991199219931994199519961997199819992000200120022003200420052006200720082009201020112012201320142015201620172018201920202021202220232024202520262027202820292030203120322033203420352036203720382039204020412042204320442045204620472048204920502051205220532054205520562057205820592060206120622063206420652066206720682069207020712072207320742075207620772078207920802081208220832084208520862087208820892090209120922093209420952096209720982099210021012102210321042105210621072108210921102111211221132114211521162117211821192120212121222123212421252126212721282129213021312132213321342135213621372138213921402141214221432144214521462147214821492150215121522153215421552156215721582159216021612162216321642165216621672168216921702171217221732174217521762177217821792180218121822183218421852186218721882189219021912192219321942195219621972198219922002201220222032204220522062207220822092210221122122213221422152216221722182219222022212222222322242225222622272228222922302231223222332234223522362237223822392240224122422243224422452246224722482249225022512252225322542255225622572258225922602261226222632264226522662267226822692270227122722273227422752276227722782279228022812282228322842285228622872288228922902291229222932294229522962297229822992300230123022303230423052306230723082309231023112312231323142315231623172318
  1. /*
  2. * Explorer desktop support
  3. *
  4. * Copyright 2006 Alexandre Julliard
  5. * Copyright 2013 Hans Leidekker for CodeWeavers
  6. *
  7. * This library is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * This library is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with this library; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
  20. */
  21. #include <stdio.h>
  22. #define COBJMACROS
  23. #define NONAMELESSUNION
  24. #define NONAMELESSSTRUCT
  25. #define OEMRESOURCE
  26. #include <windows.h>
  27. #include <rpc.h>
  28. #include <shlobj.h>
  29. #include <shellapi.h>
  30. #include "exdisp.h"
  31. #include "wine/debug.h"
  32. #include "explorer_private.h"
  33. WINE_DEFAULT_DEBUG_CHANNEL(explorer);
  34. #define DESKTOP_CLASS_ATOM ((LPCWSTR)MAKEINTATOM(32769))
  35. #define DESKTOP_ALL_ACCESS 0x01ff
  36. static const WCHAR default_driver[] = {'m','a','c',',','x','1','1',0};
  37. static BOOL using_root;
  38. struct launcher
  39. {
  40. WCHAR *path;
  41. HICON icon;
  42. WCHAR *title;
  43. };
  44. static WCHAR *desktop_folder;
  45. static WCHAR *desktop_folder_public;
  46. static int icon_cx, icon_cy, icon_offset_cx, icon_offset_cy;
  47. static int title_cx, title_cy, title_offset_cx, title_offset_cy;
  48. static int desktop_width, launcher_size, launchers_per_row;
  49. static struct launcher **launchers;
  50. static unsigned int nb_launchers, nb_allocated;
  51. static REFIID tid_ids[] =
  52. {
  53. &IID_IShellWindows,
  54. &IID_IWebBrowser2
  55. };
  56. typedef enum
  57. {
  58. IShellWindows_tid,
  59. IWebBrowser2_tid,
  60. LAST_tid
  61. } tid_t;
  62. static ITypeLib *typelib;
  63. static ITypeInfo *typeinfos[LAST_tid];
  64. static HRESULT load_typelib(void)
  65. {
  66. HRESULT hres;
  67. ITypeLib *tl;
  68. hres = LoadRegTypeLib(&LIBID_SHDocVw, 1, 0, LOCALE_SYSTEM_DEFAULT, &tl);
  69. if (FAILED(hres))
  70. {
  71. ERR("LoadRegTypeLib failed: %08x\n", hres);
  72. return hres;
  73. }
  74. if (InterlockedCompareExchangePointer((void**)&typelib, tl, NULL))
  75. ITypeLib_Release(tl);
  76. return hres;
  77. }
  78. static HRESULT get_typeinfo(tid_t tid, ITypeInfo **typeinfo)
  79. {
  80. HRESULT hres;
  81. if (!typelib)
  82. hres = load_typelib();
  83. if (!typelib)
  84. return hres;
  85. if (!typeinfos[tid]) {
  86. ITypeInfo *ti;
  87. hres = ITypeLib_GetTypeInfoOfGuid(typelib, tid_ids[tid], &ti);
  88. if (FAILED(hres)) {
  89. ERR("GetTypeInfoOfGuid(%s) failed: %08x\n", debugstr_guid(tid_ids[tid]), hres);
  90. return hres;
  91. }
  92. if (InterlockedCompareExchangePointer((void**)(typeinfos+tid), ti, NULL))
  93. ITypeInfo_Release(ti);
  94. }
  95. *typeinfo = typeinfos[tid];
  96. ITypeInfo_AddRef(*typeinfo);
  97. return S_OK;
  98. }
  99. static BOOL array_reserve(void **elements, unsigned int *capacity, unsigned int count, unsigned int size)
  100. {
  101. unsigned int new_capacity, max_capacity;
  102. void *new_elements;
  103. if (count <= *capacity)
  104. return TRUE;
  105. max_capacity = ~(SIZE_T)0 / size;
  106. if (count > max_capacity)
  107. return FALSE;
  108. new_capacity = max(4, *capacity);
  109. while (new_capacity < count && new_capacity <= max_capacity / 2)
  110. new_capacity *= 2;
  111. if (new_capacity < count)
  112. new_capacity = max_capacity;
  113. if (!(new_elements = realloc(*elements, new_capacity * size)))
  114. return FALSE;
  115. *elements = new_elements;
  116. *capacity = new_capacity;
  117. return TRUE;
  118. }
  119. static LONG cookie_counter;
  120. struct window
  121. {
  122. LONG cookie, hwnd;
  123. int class;
  124. ITEMIDLIST *pidl;
  125. };
  126. struct shellwindows
  127. {
  128. IShellWindows IShellWindows_iface;
  129. CRITICAL_SECTION cs;
  130. unsigned int count, max;
  131. struct window *windows;
  132. };
  133. /* This is not limited to desktop itself, every file browser window that
  134. explorer creates supports that. Desktop instance is special in some
  135. aspects, for example navigation is not possible, you can't show/hide it,
  136. or bring up a menu. CLSID_ShellBrowserWindow class could be used to
  137. create instances like that, and they should be registered with
  138. IShellWindows as well. */
  139. struct shellbrowserwindow
  140. {
  141. IWebBrowser2 IWebBrowser2_iface;
  142. IServiceProvider IServiceProvider_iface;
  143. IShellBrowser IShellBrowser_iface;
  144. IShellView *view;
  145. };
  146. static struct shellwindows shellwindows;
  147. static struct shellbrowserwindow desktopshellbrowserwindow;
  148. static inline struct shellwindows *impl_from_IShellWindows(IShellWindows *iface)
  149. {
  150. return CONTAINING_RECORD(iface, struct shellwindows, IShellWindows_iface);
  151. }
  152. static inline struct shellbrowserwindow *impl_from_IWebBrowser2(IWebBrowser2 *iface)
  153. {
  154. return CONTAINING_RECORD(iface, struct shellbrowserwindow, IWebBrowser2_iface);
  155. }
  156. static inline struct shellbrowserwindow *impl_from_IServiceProvider(IServiceProvider *iface)
  157. {
  158. return CONTAINING_RECORD(iface, struct shellbrowserwindow, IServiceProvider_iface);
  159. }
  160. static inline struct shellbrowserwindow *impl_from_IShellBrowser(IShellBrowser *iface)
  161. {
  162. return CONTAINING_RECORD(iface, struct shellbrowserwindow, IShellBrowser_iface);
  163. }
  164. static void shellwindows_init(void);
  165. static void desktopshellbrowserwindow_init(void);
  166. static RECT get_icon_rect( unsigned int index )
  167. {
  168. RECT rect;
  169. unsigned int row = index / launchers_per_row;
  170. unsigned int col = index % launchers_per_row;
  171. rect.left = col * launcher_size + icon_offset_cx;
  172. rect.right = rect.left + icon_cx;
  173. rect.top = row * launcher_size + icon_offset_cy;
  174. rect.bottom = rect.top + icon_cy;
  175. return rect;
  176. }
  177. static RECT get_title_rect( unsigned int index )
  178. {
  179. RECT rect;
  180. unsigned int row = index / launchers_per_row;
  181. unsigned int col = index % launchers_per_row;
  182. rect.left = col * launcher_size + title_offset_cx;
  183. rect.right = rect.left + title_cx;
  184. rect.top = row * launcher_size + title_offset_cy;
  185. rect.bottom = rect.top + title_cy;
  186. return rect;
  187. }
  188. static const struct launcher *launcher_from_point( int x, int y )
  189. {
  190. RECT icon, title;
  191. unsigned int index;
  192. if (!nb_launchers) return NULL;
  193. index = x / launcher_size + (y / launcher_size) * launchers_per_row;
  194. if (index >= nb_launchers) return NULL;
  195. icon = get_icon_rect( index );
  196. title = get_title_rect( index );
  197. if ((x < icon.left || x > icon.right || y < icon.top || y > icon.bottom) &&
  198. (x < title.left || x > title.right || y < title.top || y > title.bottom)) return NULL;
  199. return launchers[index];
  200. }
  201. static void draw_launchers( HDC hdc, RECT update_rect )
  202. {
  203. COLORREF color = SetTextColor( hdc, RGB(255,255,255) ); /* FIXME: depends on background color */
  204. int mode = SetBkMode( hdc, TRANSPARENT );
  205. unsigned int i;
  206. LOGFONTW lf;
  207. HFONT font;
  208. SystemParametersInfoW( SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0 );
  209. font = SelectObject( hdc, CreateFontIndirectW( &lf ) );
  210. for (i = 0; i < nb_launchers; i++)
  211. {
  212. RECT dummy, icon = get_icon_rect( i ), title = get_title_rect( i );
  213. if (IntersectRect( &dummy, &icon, &update_rect ))
  214. DrawIconEx( hdc, icon.left, icon.top, launchers[i]->icon, icon_cx, icon_cy,
  215. 0, 0, DI_DEFAULTSIZE|DI_NORMAL );
  216. if (IntersectRect( &dummy, &title, &update_rect ))
  217. DrawTextW( hdc, launchers[i]->title, -1, &title,
  218. DT_CENTER|DT_WORDBREAK|DT_EDITCONTROL|DT_END_ELLIPSIS );
  219. }
  220. SelectObject( hdc, font );
  221. SetTextColor( hdc, color );
  222. SetBkMode( hdc, mode );
  223. }
  224. static void do_launch( const struct launcher *launcher )
  225. {
  226. static const WCHAR openW[] = {'o','p','e','n',0};
  227. ShellExecuteW( NULL, openW, launcher->path, NULL, NULL, 0 );
  228. }
  229. static WCHAR *append_path( const WCHAR *path, const WCHAR *filename, int len_filename )
  230. {
  231. int len_path = lstrlenW( path );
  232. WCHAR *ret;
  233. if (len_filename == -1) len_filename = lstrlenW( filename );
  234. if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len_path + len_filename + 2) * sizeof(WCHAR) )))
  235. return NULL;
  236. memcpy( ret, path, len_path * sizeof(WCHAR) );
  237. ret[len_path] = '\\';
  238. memcpy( ret + len_path + 1, filename, len_filename * sizeof(WCHAR) );
  239. ret[len_path + 1 + len_filename] = 0;
  240. return ret;
  241. }
  242. static IShellLinkW *load_shelllink( const WCHAR *path )
  243. {
  244. HRESULT hr;
  245. IShellLinkW *link;
  246. IPersistFile *file;
  247. hr = CoCreateInstance( &CLSID_ShellLink, NULL, CLSCTX_INPROC_SERVER, &IID_IShellLinkW,
  248. (void **)&link );
  249. if (FAILED( hr )) return NULL;
  250. hr = IShellLinkW_QueryInterface( link, &IID_IPersistFile, (void **)&file );
  251. if (FAILED( hr ))
  252. {
  253. IShellLinkW_Release( link );
  254. return NULL;
  255. }
  256. hr = IPersistFile_Load( file, path, 0 );
  257. IPersistFile_Release( file );
  258. if (FAILED( hr ))
  259. {
  260. IShellLinkW_Release( link );
  261. return NULL;
  262. }
  263. return link;
  264. }
  265. static HICON extract_icon( IShellLinkW *link )
  266. {
  267. WCHAR tmp_path[MAX_PATH], icon_path[MAX_PATH], target_path[MAX_PATH];
  268. HICON icon = NULL;
  269. int index;
  270. tmp_path[0] = 0;
  271. IShellLinkW_GetIconLocation( link, tmp_path, MAX_PATH, &index );
  272. ExpandEnvironmentStringsW( tmp_path, icon_path, MAX_PATH );
  273. if (icon_path[0]) ExtractIconExW( icon_path, index, &icon, NULL, 1 );
  274. if (!icon)
  275. {
  276. tmp_path[0] = 0;
  277. IShellLinkW_GetPath( link, tmp_path, MAX_PATH, NULL, SLGP_RAWPATH );
  278. ExpandEnvironmentStringsW( tmp_path, target_path, MAX_PATH );
  279. ExtractIconExW( target_path, index, &icon, NULL, 1 );
  280. }
  281. return icon;
  282. }
  283. static WCHAR *build_title( const WCHAR *filename, int len )
  284. {
  285. const WCHAR *p;
  286. WCHAR *ret;
  287. if (len == -1) len = lstrlenW( filename );
  288. for (p = filename + len - 1; p >= filename; p--)
  289. {
  290. if (*p == '.')
  291. {
  292. len = p - filename;
  293. break;
  294. }
  295. }
  296. if (!(ret = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return NULL;
  297. memcpy( ret, filename, len * sizeof(WCHAR) );
  298. ret[len] = 0;
  299. return ret;
  300. }
  301. static BOOL add_launcher( const WCHAR *folder, const WCHAR *filename, int len_filename )
  302. {
  303. struct launcher *launcher;
  304. IShellLinkW *link;
  305. if (nb_launchers == nb_allocated)
  306. {
  307. unsigned int count = nb_allocated * 2;
  308. struct launcher **tmp = HeapReAlloc( GetProcessHeap(), 0, launchers, count * sizeof(*tmp) );
  309. if (!tmp) return FALSE;
  310. launchers = tmp;
  311. nb_allocated = count;
  312. }
  313. if (!(launcher = HeapAlloc( GetProcessHeap(), 0, sizeof(*launcher) ))) return FALSE;
  314. if (!(launcher->path = append_path( folder, filename, len_filename ))) goto error;
  315. if (!(link = load_shelllink( launcher->path ))) goto error;
  316. launcher->icon = extract_icon( link );
  317. launcher->title = build_title( filename, len_filename );
  318. IShellLinkW_Release( link );
  319. if (launcher->icon && launcher->title)
  320. {
  321. launchers[nb_launchers++] = launcher;
  322. return TRUE;
  323. }
  324. HeapFree( GetProcessHeap(), 0, launcher->title );
  325. DestroyIcon( launcher->icon );
  326. error:
  327. HeapFree( GetProcessHeap(), 0, launcher->path );
  328. HeapFree( GetProcessHeap(), 0, launcher );
  329. return FALSE;
  330. }
  331. static void free_launcher( struct launcher *launcher )
  332. {
  333. DestroyIcon( launcher->icon );
  334. HeapFree( GetProcessHeap(), 0, launcher->path );
  335. HeapFree( GetProcessHeap(), 0, launcher->title );
  336. HeapFree( GetProcessHeap(), 0, launcher );
  337. }
  338. static BOOL remove_launcher( const WCHAR *folder, const WCHAR *filename, int len_filename )
  339. {
  340. UINT i;
  341. WCHAR *path;
  342. BOOL ret = FALSE;
  343. if (!(path = append_path( folder, filename, len_filename ))) return FALSE;
  344. for (i = 0; i < nb_launchers; i++)
  345. {
  346. if (!wcsicmp( launchers[i]->path, path ))
  347. {
  348. free_launcher( launchers[i] );
  349. if (--nb_launchers)
  350. memmove( &launchers[i], &launchers[i + 1], sizeof(launchers[i]) * (nb_launchers - i) );
  351. ret = TRUE;
  352. break;
  353. }
  354. }
  355. HeapFree( GetProcessHeap(), 0, path );
  356. return ret;
  357. }
  358. static BOOL get_icon_text_metrics( HWND hwnd, TEXTMETRICW *tm )
  359. {
  360. BOOL ret;
  361. HDC hdc;
  362. LOGFONTW lf;
  363. HFONT hfont;
  364. hdc = GetDC( hwnd );
  365. SystemParametersInfoW( SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0 );
  366. hfont = SelectObject( hdc, CreateFontIndirectW( &lf ) );
  367. ret = GetTextMetricsW( hdc, tm );
  368. SelectObject( hdc, hfont );
  369. ReleaseDC( hwnd, hdc );
  370. return ret;
  371. }
  372. static BOOL process_changes( const WCHAR *folder, char *buf )
  373. {
  374. FILE_NOTIFY_INFORMATION *info = (FILE_NOTIFY_INFORMATION *)buf;
  375. BOOL ret = FALSE;
  376. for (;;)
  377. {
  378. switch (info->Action)
  379. {
  380. case FILE_ACTION_ADDED:
  381. case FILE_ACTION_RENAMED_NEW_NAME:
  382. if (add_launcher( folder, info->FileName, info->FileNameLength / sizeof(WCHAR) ))
  383. ret = TRUE;
  384. break;
  385. case FILE_ACTION_REMOVED:
  386. case FILE_ACTION_RENAMED_OLD_NAME:
  387. if (remove_launcher( folder, info->FileName, info->FileNameLength / sizeof(WCHAR) ))
  388. ret = TRUE;
  389. break;
  390. default:
  391. WARN( "unexpected action %u\n", info->Action );
  392. break;
  393. }
  394. if (!info->NextEntryOffset) break;
  395. info = (FILE_NOTIFY_INFORMATION *)((char *)info + info->NextEntryOffset);
  396. }
  397. return ret;
  398. }
  399. static DWORD CALLBACK watch_desktop_folders( LPVOID param )
  400. {
  401. HWND hwnd = param;
  402. HRESULT init = CoInitialize( NULL );
  403. HANDLE dir0, dir1, events[2];
  404. OVERLAPPED ovl0, ovl1;
  405. char *buf0 = NULL, *buf1 = NULL;
  406. DWORD count, size = 4096, error = ERROR_OUTOFMEMORY;
  407. BOOL ret, redraw;
  408. dir0 = CreateFileW( desktop_folder, FILE_LIST_DIRECTORY|SYNCHRONIZE, FILE_SHARE_READ|FILE_SHARE_WRITE,
  409. NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED, NULL );
  410. if (dir0 == INVALID_HANDLE_VALUE) return GetLastError();
  411. dir1 = CreateFileW( desktop_folder_public, FILE_LIST_DIRECTORY|SYNCHRONIZE, FILE_SHARE_READ|FILE_SHARE_WRITE,
  412. NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS|FILE_FLAG_OVERLAPPED, NULL );
  413. if (dir1 == INVALID_HANDLE_VALUE)
  414. {
  415. CloseHandle( dir0 );
  416. return GetLastError();
  417. }
  418. if (!(ovl0.hEvent = events[0] = CreateEventW( NULL, FALSE, FALSE, NULL ))) goto error;
  419. if (!(ovl1.hEvent = events[1] = CreateEventW( NULL, FALSE, FALSE, NULL ))) goto error;
  420. if (!(buf0 = HeapAlloc( GetProcessHeap(), 0, size ))) goto error;
  421. if (!(buf1 = HeapAlloc( GetProcessHeap(), 0, size ))) goto error;
  422. for (;;)
  423. {
  424. ret = ReadDirectoryChangesW( dir0, buf0, size, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME, NULL, &ovl0, NULL );
  425. if (!ret)
  426. {
  427. error = GetLastError();
  428. goto error;
  429. }
  430. ret = ReadDirectoryChangesW( dir1, buf1, size, FALSE, FILE_NOTIFY_CHANGE_FILE_NAME, NULL, &ovl1, NULL );
  431. if (!ret)
  432. {
  433. error = GetLastError();
  434. goto error;
  435. }
  436. redraw = FALSE;
  437. switch ((error = WaitForMultipleObjects( 2, events, FALSE, INFINITE )))
  438. {
  439. case WAIT_OBJECT_0:
  440. if (!GetOverlappedResult( dir0, &ovl0, &count, FALSE ) || !count) break;
  441. if (process_changes( desktop_folder, buf0 )) redraw = TRUE;
  442. break;
  443. case WAIT_OBJECT_0 + 1:
  444. if (!GetOverlappedResult( dir1, &ovl1, &count, FALSE ) || !count) break;
  445. if (process_changes( desktop_folder_public, buf1 )) redraw = TRUE;
  446. break;
  447. default:
  448. goto error;
  449. }
  450. if (redraw) InvalidateRect( hwnd, NULL, TRUE );
  451. }
  452. error:
  453. CloseHandle( dir0 );
  454. CloseHandle( dir1 );
  455. CloseHandle( events[0] );
  456. CloseHandle( events[1] );
  457. HeapFree( GetProcessHeap(), 0, buf0 );
  458. HeapFree( GetProcessHeap(), 0, buf1 );
  459. if (SUCCEEDED( init )) CoUninitialize();
  460. return error;
  461. }
  462. static void add_folder( const WCHAR *folder )
  463. {
  464. static const WCHAR lnkW[] = {'\\','*','.','l','n','k',0};
  465. int len = lstrlenW( folder ) + lstrlenW( lnkW );
  466. WIN32_FIND_DATAW data;
  467. HANDLE handle;
  468. WCHAR *glob;
  469. if (!(glob = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) ))) return;
  470. lstrcpyW( glob, folder );
  471. lstrcatW( glob, lnkW );
  472. if ((handle = FindFirstFileW( glob, &data )) != INVALID_HANDLE_VALUE)
  473. {
  474. do { add_launcher( folder, data.cFileName, -1 ); } while (FindNextFileW( handle, &data ));
  475. FindClose( handle );
  476. }
  477. HeapFree( GetProcessHeap(), 0, glob );
  478. }
  479. #define BORDER_SIZE 4
  480. #define PADDING_SIZE 4
  481. #define TITLE_CHARS 14
  482. static void initialize_launchers( HWND hwnd )
  483. {
  484. HRESULT hr, init;
  485. TEXTMETRICW tm;
  486. int icon_size;
  487. if (!(get_icon_text_metrics( hwnd, &tm ))) return;
  488. icon_cx = GetSystemMetrics( SM_CXICON );
  489. icon_cy = GetSystemMetrics( SM_CYICON );
  490. icon_size = max( icon_cx, icon_cy );
  491. title_cy = tm.tmHeight * 2;
  492. title_cx = max( tm.tmAveCharWidth * TITLE_CHARS, icon_size + PADDING_SIZE + title_cy );
  493. launcher_size = BORDER_SIZE + title_cx + BORDER_SIZE;
  494. icon_offset_cx = (launcher_size - icon_cx) / 2;
  495. icon_offset_cy = BORDER_SIZE + (icon_size - icon_cy) / 2;
  496. title_offset_cx = BORDER_SIZE;
  497. title_offset_cy = BORDER_SIZE + icon_size + PADDING_SIZE;
  498. desktop_width = GetSystemMetrics( SM_CXSCREEN );
  499. launchers_per_row = desktop_width / launcher_size;
  500. if (!launchers_per_row) launchers_per_row = 1;
  501. hr = SHGetKnownFolderPath( &FOLDERID_Desktop, KF_FLAG_CREATE, NULL, &desktop_folder );
  502. if (FAILED( hr ))
  503. {
  504. WINE_ERR("Could not get user desktop folder\n");
  505. return;
  506. }
  507. hr = SHGetKnownFolderPath( &FOLDERID_PublicDesktop, KF_FLAG_CREATE, NULL, &desktop_folder_public );
  508. if (FAILED( hr ))
  509. {
  510. WINE_ERR("Could not get public desktop folder\n");
  511. CoTaskMemFree( desktop_folder );
  512. return;
  513. }
  514. if ((launchers = HeapAlloc( GetProcessHeap(), 0, 2 * sizeof(launchers[0]) )))
  515. {
  516. nb_allocated = 2;
  517. init = CoInitialize( NULL );
  518. add_folder( desktop_folder );
  519. add_folder( desktop_folder_public );
  520. if (SUCCEEDED( init )) CoUninitialize();
  521. CreateThread( NULL, 0, watch_desktop_folders, hwnd, 0, NULL );
  522. }
  523. }
  524. static WNDPROC desktop_orig_wndproc;
  525. /* window procedure for the desktop window */
  526. static LRESULT WINAPI desktop_wnd_proc( HWND hwnd, UINT message, WPARAM wp, LPARAM lp )
  527. {
  528. WINE_TRACE( "got msg %04x wp %lx lp %lx\n", message, wp, lp );
  529. switch(message)
  530. {
  531. case WM_SYSCOMMAND:
  532. switch(wp & 0xfff0)
  533. {
  534. case SC_CLOSE:
  535. ExitWindows( 0, 0 );
  536. return 0;
  537. }
  538. break;
  539. case WM_CLOSE:
  540. PostQuitMessage(0);
  541. return 0;
  542. case WM_SETCURSOR:
  543. return (LRESULT)SetCursor( LoadCursorA( 0, (LPSTR)IDC_ARROW ) );
  544. case WM_NCHITTEST:
  545. return HTCLIENT;
  546. case WM_ERASEBKGND:
  547. if (!using_root) PaintDesktop( (HDC)wp );
  548. return TRUE;
  549. case WM_SETTINGCHANGE:
  550. if (wp == SPI_SETDESKWALLPAPER)
  551. SystemParametersInfoW( SPI_SETDESKWALLPAPER, 0, NULL, FALSE );
  552. return 0;
  553. case WM_PARENTNOTIFY:
  554. handle_parent_notify( (HWND)lp, wp );
  555. return 0;
  556. case WM_LBUTTONDBLCLK:
  557. if (!using_root)
  558. {
  559. const struct launcher *launcher = launcher_from_point( (short)LOWORD(lp), (short)HIWORD(lp) );
  560. if (launcher) do_launch( launcher );
  561. }
  562. return 0;
  563. case WM_PAINT:
  564. {
  565. PAINTSTRUCT ps;
  566. BeginPaint( hwnd, &ps );
  567. if (!using_root)
  568. {
  569. if (ps.fErase) PaintDesktop( ps.hdc );
  570. draw_launchers( ps.hdc, ps.rcPaint );
  571. }
  572. EndPaint( hwnd, &ps );
  573. }
  574. return 0;
  575. }
  576. return desktop_orig_wndproc( hwnd, message, wp, lp );
  577. }
  578. /* create the desktop and the associated driver window, and make it the current desktop */
  579. static BOOL create_desktop( HMODULE driver, const WCHAR *name, unsigned int width, unsigned int height )
  580. {
  581. BOOL ret = FALSE;
  582. BOOL (CDECL *create_desktop_func)(unsigned int, unsigned int);
  583. if (driver)
  584. {
  585. create_desktop_func = (void *)GetProcAddress( driver, "wine_create_desktop" );
  586. if (create_desktop_func) ret = create_desktop_func( width, height );
  587. }
  588. return ret;
  589. }
  590. /* parse the desktop size specification */
  591. static BOOL parse_size( const WCHAR *size, unsigned int *width, unsigned int *height )
  592. {
  593. WCHAR *end;
  594. *width = wcstoul( size, &end, 10 );
  595. if (end == size) return FALSE;
  596. if (*end != 'x') return FALSE;
  597. size = end + 1;
  598. *height = wcstoul( size, &end, 10 );
  599. return !*end;
  600. }
  601. /* retrieve the desktop name to use if not specified on the command line */
  602. static const WCHAR *get_default_desktop_name(void)
  603. {
  604. static const WCHAR desktopW[] = {'D','e','s','k','t','o','p',0};
  605. static const WCHAR defaultW[] = {'D','e','f','a','u','l','t',0};
  606. static const WCHAR explorer_keyW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
  607. 'E','x','p','l','o','r','e','r',0};
  608. static WCHAR buffer[MAX_PATH];
  609. DWORD size = sizeof(buffer);
  610. HDESK desk = GetThreadDesktop( GetCurrentThreadId() );
  611. WCHAR *ret = NULL;
  612. HKEY hkey;
  613. if (desk && GetUserObjectInformationW( desk, UOI_NAME, buffer, ARRAY_SIZE( buffer ), NULL ))
  614. {
  615. if (wcsicmp( buffer, defaultW )) return buffer;
  616. }
  617. /* @@ Wine registry key: HKCU\Software\Wine\Explorer */
  618. if (!RegOpenKeyW( HKEY_CURRENT_USER, explorer_keyW, &hkey ))
  619. {
  620. if (!RegQueryValueExW( hkey, desktopW, 0, NULL, (LPBYTE)buffer, &size ) && *buffer) ret = buffer;
  621. RegCloseKey( hkey );
  622. }
  623. return ret;
  624. }
  625. /* retrieve the default desktop size from the registry */
  626. static BOOL get_default_desktop_size( const WCHAR *name, unsigned int *width, unsigned int *height )
  627. {
  628. static const WCHAR desktop_keyW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
  629. 'E','x','p','l','o','r','e','r','\\',
  630. 'D','e','s','k','t','o','p','s',0};
  631. HKEY hkey;
  632. WCHAR buffer[64];
  633. DWORD size = sizeof(buffer);
  634. BOOL found = FALSE;
  635. *width = 800;
  636. *height = 600;
  637. /* @@ Wine registry key: HKCU\Software\Wine\Explorer\Desktops */
  638. if (!RegOpenKeyW( HKEY_CURRENT_USER, desktop_keyW, &hkey ))
  639. {
  640. if (!RegQueryValueExW( hkey, name, 0, NULL, (LPBYTE)buffer, &size ))
  641. {
  642. found = TRUE;
  643. if (!parse_size( buffer, width, height )) *width = *height = 0;
  644. }
  645. RegCloseKey( hkey );
  646. }
  647. return found;
  648. }
  649. static BOOL get_default_enable_shell( const WCHAR *name )
  650. {
  651. static const WCHAR desktop_keyW[] = {'S','o','f','t','w','a','r','e','\\','W','i','n','e','\\',
  652. 'E','x','p','l','o','r','e','r','\\',
  653. 'D','e','s','k','t','o','p','s',0};
  654. static const WCHAR enable_shellW[] = {'E','n','a','b','l','e','S','h','e','l','l',0};
  655. static const WCHAR shellW[] = {'s','h','e','l','l',0};
  656. HKEY hkey;
  657. BOOL found = FALSE;
  658. BOOL result;
  659. DWORD size = sizeof(result);
  660. /* @@ Wine registry key: HKCU\Software\Wine\Explorer\Desktops */
  661. if (!RegOpenKeyW( HKEY_CURRENT_USER, desktop_keyW, &hkey ))
  662. {
  663. if (!RegGetValueW( hkey, name, enable_shellW, RRF_RT_REG_DWORD, NULL, &result, &size ))
  664. found = TRUE;
  665. RegCloseKey( hkey );
  666. }
  667. /* Default off, except for the magic desktop name "shell" */
  668. if (!found)
  669. result = (lstrcmpiW( name, shellW ) == 0);
  670. return result;
  671. }
  672. static HMODULE load_graphics_driver( const WCHAR *driver, const GUID *guid )
  673. {
  674. static const WCHAR device_keyW[] = {
  675. 'S','y','s','t','e','m','\\',
  676. 'C','u','r','r','e','n','t','C','o','n','t','r','o','l','S','e','t','\\',
  677. 'C','o','n','t','r','o','l','\\',
  678. 'V','i','d','e','o','\\',
  679. '{','%','0','8','x','-','%','0','4','x','-','%','0','4','x','-',
  680. '%','0','2','x','%','0','2','x','-','%','0','2','x','%','0','2','x','%','0','2','x',
  681. '%','0','2','x','%','0','2','x','%','0','2','x','}','\\','0','0','0','0',0};
  682. static const WCHAR graphics_driverW[] = {'G','r','a','p','h','i','c','s','D','r','i','v','e','r',0};
  683. static const WCHAR driversW[] = {'S','o','f','t','w','a','r','e','\\',
  684. 'W','i','n','e','\\','D','r','i','v','e','r','s',0};
  685. static const WCHAR graphicsW[] = {'G','r','a','p','h','i','c','s',0};
  686. static const WCHAR drv_formatW[] = {'w','i','n','e','%','s','.','d','r','v',0};
  687. WCHAR buffer[MAX_PATH], libname[32], *name, *next;
  688. WCHAR key[ARRAY_SIZE( device_keyW ) + 39];
  689. BOOL null_driver = FALSE;
  690. HMODULE module = 0;
  691. HKEY hkey;
  692. char error[80];
  693. if (!driver)
  694. {
  695. lstrcpyW( buffer, default_driver );
  696. /* @@ Wine registry key: HKCU\Software\Wine\Drivers */
  697. if (!RegOpenKeyW( HKEY_CURRENT_USER, driversW, &hkey ))
  698. {
  699. DWORD count = sizeof(buffer);
  700. RegQueryValueExW( hkey, graphicsW, 0, NULL, (LPBYTE)buffer, &count );
  701. RegCloseKey( hkey );
  702. }
  703. }
  704. else lstrcpynW( buffer, driver, ARRAY_SIZE( buffer ));
  705. name = buffer;
  706. while (name)
  707. {
  708. next = wcschr( name, ',' );
  709. if (next) *next++ = 0;
  710. if (!wcscmp( name, L"null" ))
  711. {
  712. TRACE( "display %s using null driver\n", debugstr_guid(guid) );
  713. wcscpy( libname, L"null" );
  714. null_driver = TRUE;
  715. break;
  716. }
  717. swprintf( libname, ARRAY_SIZE( libname ), drv_formatW, name );
  718. if ((module = LoadLibraryW( libname )) != 0) break;
  719. switch (GetLastError())
  720. {
  721. case ERROR_MOD_NOT_FOUND:
  722. strcpy( error, "The graphics driver is missing. Check your build!" );
  723. break;
  724. case ERROR_DLL_INIT_FAILED:
  725. strcpy( error, "Make sure that your X server is running and that $DISPLAY is set correctly." );
  726. break;
  727. default:
  728. sprintf( error, "Unknown error (%u).", GetLastError() );
  729. break;
  730. }
  731. name = next;
  732. }
  733. TRACE( "display %s driver %s\n", debugstr_guid(guid), debugstr_w(libname) );
  734. swprintf( key, ARRAY_SIZE(key), device_keyW, guid->Data1, guid->Data2, guid->Data3,
  735. guid->Data4[0], guid->Data4[1], guid->Data4[2], guid->Data4[3],
  736. guid->Data4[4], guid->Data4[5], guid->Data4[6], guid->Data4[7] );
  737. if (!RegCreateKeyExW( HKEY_LOCAL_MACHINE, key, 0, NULL,
  738. REG_OPTION_VOLATILE, KEY_SET_VALUE, NULL, &hkey, NULL ))
  739. {
  740. if (module || null_driver)
  741. RegSetValueExW( hkey, graphics_driverW, 0, REG_SZ,
  742. (BYTE *)libname, (lstrlenW(libname) + 1) * sizeof(WCHAR) );
  743. else
  744. RegSetValueExA( hkey, "DriverError", 0, REG_SZ, (BYTE *)error, strlen(error) + 1 );
  745. RegCloseKey( hkey );
  746. }
  747. return module;
  748. }
  749. static void initialize_display_settings(void)
  750. {
  751. DISPLAY_DEVICEW ddW;
  752. DEVMODEW dmW;
  753. DWORD i = 0;
  754. /* Store current display mode in the registry */
  755. ddW.cb = sizeof(ddW);
  756. memset(&dmW, 0, sizeof(dmW));
  757. dmW.dmSize = sizeof(dmW);
  758. while (EnumDisplayDevicesW( NULL, i++, &ddW, 0 ))
  759. {
  760. if (!EnumDisplaySettingsExW( ddW.DeviceName, ENUM_CURRENT_SETTINGS, &dmW, 0))
  761. {
  762. WINE_ERR( "Failed to query current display settings for %s.\n",
  763. wine_dbgstr_w( ddW.DeviceName ) );
  764. continue;
  765. }
  766. WINE_TRACE( "Device %s current display mode %ux%u %uBits %uHz at %d,%d.\n",
  767. wine_dbgstr_w( ddW.DeviceName ), dmW.dmPelsWidth, dmW.dmPelsHeight,
  768. dmW.dmBitsPerPel, dmW.dmDisplayFrequency, dmW.u1.s2.dmPosition.x,
  769. dmW.u1.s2.dmPosition.y );
  770. if (ChangeDisplaySettingsExW( ddW.DeviceName, &dmW, 0,
  771. CDS_GLOBAL | CDS_NORESET | CDS_UPDATEREGISTRY, 0 ))
  772. WINE_ERR( "Failed to initialize registry display settings for %s.\n",
  773. wine_dbgstr_w( ddW.DeviceName ) );
  774. }
  775. }
  776. static void set_desktop_window_title( HWND hwnd, const WCHAR *name )
  777. {
  778. static const WCHAR desktop_nameW[] = {'W','i','n','e',' ','d','e','s','k','t','o','p',0};
  779. static const WCHAR desktop_name_separatorW[] = {' ', '-', ' ', 0};
  780. WCHAR *window_titleW = NULL;
  781. int window_title_len;
  782. if (!name[0])
  783. {
  784. SetWindowTextW( hwnd, desktop_nameW );
  785. return;
  786. }
  787. window_title_len = lstrlenW(name) * sizeof(WCHAR)
  788. + sizeof(desktop_name_separatorW)
  789. + sizeof(desktop_nameW);
  790. window_titleW = HeapAlloc( GetProcessHeap(), 0, window_title_len );
  791. if (!window_titleW)
  792. {
  793. SetWindowTextW( hwnd, desktop_nameW );
  794. return;
  795. }
  796. lstrcpyW( window_titleW, name );
  797. lstrcatW( window_titleW, desktop_name_separatorW );
  798. lstrcatW( window_titleW, desktop_nameW );
  799. SetWindowTextW( hwnd, window_titleW );
  800. HeapFree( GetProcessHeap(), 0, window_titleW );
  801. }
  802. static inline BOOL is_whitespace(WCHAR c)
  803. {
  804. return c == ' ' || c == '\t';
  805. }
  806. /* main desktop management function */
  807. void manage_desktop( WCHAR *arg )
  808. {
  809. static const WCHAR messageW[] = {'M','e','s','s','a','g','e',0};
  810. HDESK desktop = 0;
  811. GUID guid;
  812. MSG msg;
  813. HWND hwnd;
  814. HMODULE graphics_driver;
  815. unsigned int width, height;
  816. WCHAR *cmdline = NULL, *driver = NULL;
  817. WCHAR *p = arg;
  818. const WCHAR *name = NULL;
  819. BOOL enable_shell = FALSE;
  820. void (WINAPI *pShellDDEInit)( BOOL ) = NULL;
  821. HMODULE shell32;
  822. /* get the rest of the command line (if any) */
  823. while (*p && !is_whitespace(*p)) p++;
  824. if (*p)
  825. {
  826. *p++ = 0;
  827. while (*p && is_whitespace(*p)) p++;
  828. if (*p) cmdline = p;
  829. }
  830. /* parse the desktop option */
  831. /* the option is of the form /desktop=name[,widthxheight[,driver]] */
  832. if ((arg[0] == '=' || arg[0] == ',') && arg[1] && arg[1] != ',')
  833. {
  834. arg++;
  835. name = arg;
  836. if ((p = wcschr( arg, ',' )))
  837. {
  838. *p++ = 0;
  839. if ((driver = wcschr( p, ',' ))) *driver++ = 0;
  840. }
  841. if (!p || !parse_size( p, &width, &height ))
  842. get_default_desktop_size( name, &width, &height );
  843. }
  844. else if ((name = get_default_desktop_name()))
  845. {
  846. if (!get_default_desktop_size( name, &width, &height )) width = height = 0;
  847. }
  848. if (name)
  849. enable_shell = get_default_enable_shell( name );
  850. if (name && width && height)
  851. {
  852. if (!(desktop = CreateDesktopW( name, NULL, NULL, 0, DESKTOP_ALL_ACCESS, NULL )))
  853. {
  854. WINE_ERR( "failed to create desktop %s error %d\n", wine_dbgstr_w(name), GetLastError() );
  855. ExitProcess( 1 );
  856. }
  857. SetThreadDesktop( desktop );
  858. }
  859. UuidCreate( &guid );
  860. TRACE( "display guid %s\n", debugstr_guid(&guid) );
  861. graphics_driver = load_graphics_driver( driver, &guid );
  862. /* create the desktop window */
  863. hwnd = CreateWindowExW( 0, DESKTOP_CLASS_ATOM, NULL,
  864. WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN, 0, 0, 0, 0, 0, 0, 0, &guid );
  865. if (hwnd)
  866. {
  867. /* create the HWND_MESSAGE parent */
  868. CreateWindowExW( 0, messageW, NULL, WS_POPUP | WS_CLIPSIBLINGS | WS_CLIPCHILDREN,
  869. 0, 0, 100, 100, 0, 0, 0, NULL );
  870. desktop_orig_wndproc = (WNDPROC)SetWindowLongPtrW( hwnd, GWLP_WNDPROC,
  871. (LONG_PTR)desktop_wnd_proc );
  872. using_root = !desktop || !create_desktop( graphics_driver, name, width, height );
  873. SendMessageW( hwnd, WM_SETICON, ICON_BIG, (LPARAM)LoadIconW( 0, MAKEINTRESOURCEW(OIC_WINLOGO)));
  874. if (name) set_desktop_window_title( hwnd, name );
  875. SetWindowPos( hwnd, 0, GetSystemMetrics(SM_XVIRTUALSCREEN), GetSystemMetrics(SM_YVIRTUALSCREEN),
  876. GetSystemMetrics(SM_CXVIRTUALSCREEN), GetSystemMetrics(SM_CYVIRTUALSCREEN),
  877. SWP_SHOWWINDOW );
  878. SystemParametersInfoW( SPI_SETDESKWALLPAPER, 0, NULL, FALSE );
  879. ClipCursor( NULL );
  880. initialize_display_settings();
  881. initialize_appbar();
  882. if (using_root) enable_shell = FALSE;
  883. initialize_systray( graphics_driver, using_root, enable_shell );
  884. if (!using_root) initialize_launchers( hwnd );
  885. if ((shell32 = LoadLibraryW( L"shell32.dll" )) &&
  886. (pShellDDEInit = (void *)GetProcAddress( shell32, (LPCSTR)188)))
  887. {
  888. pShellDDEInit( TRUE );
  889. }
  890. }
  891. /* if we have a command line, execute it */
  892. if (cmdline)
  893. {
  894. STARTUPINFOW si;
  895. PROCESS_INFORMATION pi;
  896. memset( &si, 0, sizeof(si) );
  897. si.cb = sizeof(si);
  898. WINE_TRACE( "starting %s\n", wine_dbgstr_w(cmdline) );
  899. if (CreateProcessW( NULL, cmdline, NULL, NULL, FALSE, 0, NULL, NULL, &si, &pi ))
  900. {
  901. CloseHandle( pi.hThread );
  902. CloseHandle( pi.hProcess );
  903. }
  904. }
  905. desktopshellbrowserwindow_init();
  906. shellwindows_init();
  907. /* run the desktop message loop */
  908. if (hwnd)
  909. {
  910. WINE_TRACE( "desktop message loop starting on hwnd %p\n", hwnd );
  911. while (GetMessageW( &msg, 0, 0, 0 )) DispatchMessageW( &msg );
  912. WINE_TRACE( "desktop message loop exiting for hwnd %p\n", hwnd );
  913. }
  914. if (pShellDDEInit) pShellDDEInit( FALSE );
  915. ExitProcess( 0 );
  916. }
  917. /* IShellWindows implementation */
  918. static HRESULT WINAPI shellwindows_QueryInterface(IShellWindows *iface, REFIID riid, void **ppvObject)
  919. {
  920. struct shellwindows *This = impl_from_IShellWindows(iface);
  921. TRACE("%s %p\n", debugstr_guid(riid), ppvObject);
  922. if (IsEqualGUID(riid, &IID_IShellWindows) ||
  923. IsEqualGUID(riid, &IID_IDispatch) ||
  924. IsEqualGUID(riid, &IID_IUnknown))
  925. {
  926. *ppvObject = &This->IShellWindows_iface;
  927. }
  928. else
  929. {
  930. WARN("Unsupported interface %s\n", debugstr_guid(riid));
  931. *ppvObject = NULL;
  932. }
  933. if (*ppvObject)
  934. {
  935. IUnknown_AddRef((IUnknown*)*ppvObject);
  936. return S_OK;
  937. }
  938. return E_NOINTERFACE;
  939. }
  940. static ULONG WINAPI shellwindows_AddRef(IShellWindows *iface)
  941. {
  942. return 2;
  943. }
  944. static ULONG WINAPI shellwindows_Release(IShellWindows *iface)
  945. {
  946. return 1;
  947. }
  948. static HRESULT WINAPI shellwindows_GetTypeInfoCount(IShellWindows *iface, UINT *pctinfo)
  949. {
  950. TRACE("%p\n", pctinfo);
  951. *pctinfo = 1;
  952. return S_OK;
  953. }
  954. static HRESULT WINAPI shellwindows_GetTypeInfo(IShellWindows *iface,
  955. UINT iTInfo, LCID lcid, ITypeInfo **ppTInfo)
  956. {
  957. TRACE("%d %d %p\n", iTInfo, lcid, ppTInfo);
  958. return get_typeinfo(IShellWindows_tid, ppTInfo);
  959. }
  960. static HRESULT WINAPI shellwindows_GetIDsOfNames(IShellWindows *iface,
  961. REFIID riid, LPOLESTR *rgszNames, UINT cNames, LCID lcid,
  962. DISPID *rgDispId)
  963. {
  964. ITypeInfo *typeinfo;
  965. HRESULT hr;
  966. TRACE("%s %p %d %d %p\n", debugstr_guid(riid), rgszNames, cNames,
  967. lcid, rgDispId);
  968. if (!rgszNames || cNames == 0 || !rgDispId)
  969. return E_INVALIDARG;
  970. hr = get_typeinfo(IShellWindows_tid, &typeinfo);
  971. if (SUCCEEDED(hr))
  972. {
  973. hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
  974. ITypeInfo_Release(typeinfo);
  975. }
  976. return hr;
  977. }
  978. static HRESULT WINAPI shellwindows_Invoke(IShellWindows *iface,
  979. DISPID dispIdMember, REFIID riid, LCID lcid, WORD wFlags,
  980. DISPPARAMS *pDispParams, VARIANT *pVarResult,
  981. EXCEPINFO *pExcepInfo, UINT *puArgErr)
  982. {
  983. ITypeInfo *typeinfo;
  984. HRESULT hr;
  985. TRACE("%d %s %d %08x %p %p %p %p\n", dispIdMember, debugstr_guid(riid),
  986. lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
  987. hr = get_typeinfo(IShellWindows_tid, &typeinfo);
  988. if (SUCCEEDED(hr))
  989. {
  990. hr = ITypeInfo_Invoke(typeinfo, iface, dispIdMember, wFlags,
  991. pDispParams, pVarResult, pExcepInfo, puArgErr);
  992. ITypeInfo_Release(typeinfo);
  993. }
  994. return hr;
  995. }
  996. static HRESULT WINAPI shellwindows_get_Count(IShellWindows *iface, LONG *count)
  997. {
  998. FIXME("%p\n", count);
  999. return E_NOTIMPL;
  1000. }
  1001. static HRESULT WINAPI shellwindows_Item(IShellWindows *iface, VARIANT index,
  1002. IDispatch **folder)
  1003. {
  1004. FIXME("%s %p\n", debugstr_variant(&index), folder);
  1005. return E_NOTIMPL;
  1006. }
  1007. static HRESULT WINAPI shellwindows__NewEnum(IShellWindows *iface, IUnknown **ppunk)
  1008. {
  1009. FIXME("%p\n", ppunk);
  1010. return E_NOTIMPL;
  1011. }
  1012. static HRESULT WINAPI shellwindows_Register(IShellWindows *iface,
  1013. IDispatch *disp, LONG hwnd, int class, LONG *cookie)
  1014. {
  1015. struct shellwindows *sw = impl_from_IShellWindows(iface);
  1016. struct window *window;
  1017. TRACE("iface %p, disp %p, hwnd %#x, class %u, cookie %p.\n", iface, disp, hwnd, class, cookie);
  1018. if (!hwnd)
  1019. return E_POINTER;
  1020. if (disp)
  1021. FIXME("Ignoring IDispatch %p.\n", disp);
  1022. EnterCriticalSection(&sw->cs);
  1023. if (!array_reserve((void **)&sw->windows, &sw->max, sw->count + 1, sizeof(*sw->windows)))
  1024. {
  1025. LeaveCriticalSection(&sw->cs);
  1026. return E_OUTOFMEMORY;
  1027. }
  1028. window = &sw->windows[sw->count++];
  1029. window->hwnd = hwnd;
  1030. window->class = class;
  1031. *cookie = window->cookie = ++cookie_counter;
  1032. window->pidl = NULL;
  1033. LeaveCriticalSection(&sw->cs);
  1034. return S_OK;
  1035. }
  1036. static HRESULT WINAPI shellwindows_RegisterPending(IShellWindows *iface,
  1037. LONG threadid, VARIANT *loc, VARIANT *root, int class, LONG *cookie)
  1038. {
  1039. FIXME("0x%x %s %s 0x%x %p\n", threadid, debugstr_variant(loc), debugstr_variant(root),
  1040. class, cookie);
  1041. return E_NOTIMPL;
  1042. }
  1043. static HRESULT WINAPI shellwindows_Revoke(IShellWindows *iface, LONG cookie)
  1044. {
  1045. struct shellwindows *sw = impl_from_IShellWindows(iface);
  1046. unsigned int i;
  1047. TRACE("iface %p, cookie %u.\n", iface, cookie);
  1048. EnterCriticalSection(&sw->cs);
  1049. for (i = 0; i < sw->count; ++i)
  1050. {
  1051. if (sw->windows[i].cookie == cookie)
  1052. {
  1053. --sw->count;
  1054. memmove(&sw->windows[i], &sw->windows[i + 1], (sw->count - i) * sizeof(*sw->windows));
  1055. LeaveCriticalSection(&sw->cs);
  1056. return S_OK;
  1057. }
  1058. }
  1059. LeaveCriticalSection(&sw->cs);
  1060. return S_FALSE;
  1061. }
  1062. static HRESULT WINAPI shellwindows_OnNavigate(IShellWindows *iface, LONG cookie, VARIANT *location)
  1063. {
  1064. struct shellwindows *sw = impl_from_IShellWindows(iface);
  1065. unsigned int i;
  1066. TRACE("iface %p, cookie %u, location %s.\n", iface, cookie, debugstr_variant(location));
  1067. if (V_VT(location) != (VT_ARRAY | VT_UI1))
  1068. {
  1069. FIXME("Unexpected variant type %s.\n", debugstr_vt(V_VT(location)));
  1070. return E_NOTIMPL;
  1071. }
  1072. EnterCriticalSection(&sw->cs);
  1073. for (i = 0; i < sw->count; ++i)
  1074. {
  1075. if (sw->windows[i].cookie == cookie)
  1076. {
  1077. size_t len = V_ARRAY(location)->rgsabound[0].cElements;
  1078. if (!(sw->windows[i].pidl = realloc(sw->windows[i].pidl, len)))
  1079. {
  1080. LeaveCriticalSection(&sw->cs);
  1081. return E_OUTOFMEMORY;
  1082. }
  1083. memcpy(sw->windows[i].pidl, V_ARRAY(location)->pvData, len);
  1084. LeaveCriticalSection(&sw->cs);
  1085. return S_OK;
  1086. }
  1087. }
  1088. LeaveCriticalSection(&sw->cs);
  1089. return E_INVALIDARG;
  1090. }
  1091. static HRESULT WINAPI shellwindows_OnActivated(IShellWindows *iface, LONG cookie, VARIANT_BOOL active)
  1092. {
  1093. FIXME("0x%x 0x%x\n", cookie, active);
  1094. return E_NOTIMPL;
  1095. }
  1096. static HRESULT WINAPI shellwindows_FindWindowSW(IShellWindows *iface, VARIANT *location,
  1097. VARIANT *root, int class, LONG *hwnd, int options, IDispatch **disp)
  1098. {
  1099. struct shellwindows *sw = impl_from_IShellWindows(iface);
  1100. unsigned int i;
  1101. TRACE("iface %p, location %p, root %p, class %#x, hwnd %p, options %#x, disp %p.\n",
  1102. iface, location, root, class, hwnd, options, disp);
  1103. if (class == SWC_DESKTOP)
  1104. {
  1105. *hwnd = (LONG)(LONG_PTR)GetDesktopWindow();
  1106. if (options & SWFO_NEEDDISPATCH)
  1107. {
  1108. *disp = (IDispatch *)&desktopshellbrowserwindow.IWebBrowser2_iface;
  1109. IDispatch_AddRef(*disp);
  1110. }
  1111. return S_OK;
  1112. }
  1113. if (options)
  1114. FIXME("Ignoring options %#x.\n", options);
  1115. if (V_VT(location) != (VT_ARRAY | VT_UI1))
  1116. {
  1117. FIXME("Unexpected variant type %s.\n", debugstr_vt(V_VT(location)));
  1118. return E_NOTIMPL;
  1119. }
  1120. EnterCriticalSection(&sw->cs);
  1121. for (i = 0; i < sw->count; ++i)
  1122. {
  1123. if (sw->windows[i].class == class && ILIsEqual(V_ARRAY(location)->pvData, sw->windows[i].pidl))
  1124. {
  1125. *hwnd = sw->windows[i].hwnd;
  1126. LeaveCriticalSection(&sw->cs);
  1127. return S_OK;
  1128. }
  1129. }
  1130. LeaveCriticalSection(&sw->cs);
  1131. return S_FALSE;
  1132. }
  1133. static HRESULT WINAPI shellwindows_OnCreated(IShellWindows *iface, LONG cookie, IUnknown *punk)
  1134. {
  1135. FIXME("0x%x %p\n", cookie, punk);
  1136. return E_NOTIMPL;
  1137. }
  1138. static HRESULT WINAPI shellwindows_ProcessAttachDetach(IShellWindows *iface, VARIANT_BOOL attach)
  1139. {
  1140. FIXME("0x%x\n", attach);
  1141. return E_NOTIMPL;
  1142. }
  1143. static const IShellWindowsVtbl shellwindowsvtbl =
  1144. {
  1145. shellwindows_QueryInterface,
  1146. shellwindows_AddRef,
  1147. shellwindows_Release,
  1148. shellwindows_GetTypeInfoCount,
  1149. shellwindows_GetTypeInfo,
  1150. shellwindows_GetIDsOfNames,
  1151. shellwindows_Invoke,
  1152. shellwindows_get_Count,
  1153. shellwindows_Item,
  1154. shellwindows__NewEnum,
  1155. shellwindows_Register,
  1156. shellwindows_RegisterPending,
  1157. shellwindows_Revoke,
  1158. shellwindows_OnNavigate,
  1159. shellwindows_OnActivated,
  1160. shellwindows_FindWindowSW,
  1161. shellwindows_OnCreated,
  1162. shellwindows_ProcessAttachDetach
  1163. };
  1164. struct shellwindows_classfactory
  1165. {
  1166. IClassFactory IClassFactory_iface;
  1167. DWORD classreg;
  1168. };
  1169. static inline struct shellwindows_classfactory *impl_from_IClassFactory(IClassFactory *iface)
  1170. {
  1171. return CONTAINING_RECORD(iface, struct shellwindows_classfactory, IClassFactory_iface);
  1172. }
  1173. static HRESULT WINAPI swclassfactory_QueryInterface(IClassFactory *iface, REFIID riid, void **ppvObject)
  1174. {
  1175. struct shellwindows_classfactory *This = impl_from_IClassFactory(iface);
  1176. TRACE("%s %p\n", debugstr_guid(riid), ppvObject);
  1177. if (IsEqualGUID(riid, &IID_IUnknown) || IsEqualGUID(riid, &IID_IClassFactory))
  1178. {
  1179. *ppvObject = &This->IClassFactory_iface;
  1180. }
  1181. else
  1182. {
  1183. WARN("Unsupported interface %s\n", debugstr_guid(riid));
  1184. *ppvObject = NULL;
  1185. }
  1186. if (*ppvObject)
  1187. {
  1188. IUnknown_AddRef((IUnknown*)*ppvObject);
  1189. return S_OK;
  1190. }
  1191. return E_NOINTERFACE;
  1192. }
  1193. static ULONG WINAPI swclassfactory_AddRef(IClassFactory *iface)
  1194. {
  1195. return 2;
  1196. }
  1197. static ULONG WINAPI swclassfactory_Release(IClassFactory *iface)
  1198. {
  1199. return 1;
  1200. }
  1201. static HRESULT WINAPI swclassfactory_CreateInstance(IClassFactory *iface,
  1202. IUnknown *pUnkOuter, REFIID riid, void **ppvObject)
  1203. {
  1204. TRACE("%p %s %p\n", pUnkOuter, debugstr_guid(riid), ppvObject);
  1205. return IShellWindows_QueryInterface(&shellwindows.IShellWindows_iface, riid, ppvObject);
  1206. }
  1207. static HRESULT WINAPI swclassfactory_LockServer(IClassFactory *iface, BOOL lock)
  1208. {
  1209. TRACE("%u\n", lock);
  1210. return E_NOTIMPL;
  1211. }
  1212. static const IClassFactoryVtbl swclassfactoryvtbl =
  1213. {
  1214. swclassfactory_QueryInterface,
  1215. swclassfactory_AddRef,
  1216. swclassfactory_Release,
  1217. swclassfactory_CreateInstance,
  1218. swclassfactory_LockServer
  1219. };
  1220. static struct shellwindows_classfactory shellwindows_classfactory = { { &swclassfactoryvtbl } };
  1221. static HRESULT WINAPI webbrowser_QueryInterface(IWebBrowser2 *iface, REFIID riid, void **ppv)
  1222. {
  1223. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1224. *ppv = NULL;
  1225. if (IsEqualGUID(&IID_IWebBrowser2, riid) ||
  1226. IsEqualGUID(&IID_IWebBrowserApp, riid) ||
  1227. IsEqualGUID(&IID_IWebBrowser, riid) ||
  1228. IsEqualGUID(&IID_IDispatch, riid) ||
  1229. IsEqualGUID(&IID_IUnknown, riid))
  1230. {
  1231. *ppv = &This->IWebBrowser2_iface;
  1232. }
  1233. else if (IsEqualGUID(&IID_IServiceProvider, riid))
  1234. {
  1235. *ppv = &This->IServiceProvider_iface;
  1236. }
  1237. if (*ppv)
  1238. {
  1239. IUnknown_AddRef((IUnknown*)*ppv);
  1240. return S_OK;
  1241. }
  1242. FIXME("(%p)->(%s %p) interface not supported\n", This, debugstr_guid(riid), ppv);
  1243. return E_NOINTERFACE;
  1244. }
  1245. static ULONG WINAPI webbrowser_AddRef(IWebBrowser2 *iface)
  1246. {
  1247. return 2;
  1248. }
  1249. static ULONG WINAPI webbrowser_Release(IWebBrowser2 *iface)
  1250. {
  1251. return 1;
  1252. }
  1253. /* IDispatch methods */
  1254. static HRESULT WINAPI webbrowser_GetTypeInfoCount(IWebBrowser2 *iface, UINT *pctinfo)
  1255. {
  1256. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1257. TRACE("(%p)->(%p)\n", This, pctinfo);
  1258. *pctinfo = 1;
  1259. return S_OK;
  1260. }
  1261. static HRESULT WINAPI webbrowser_GetTypeInfo(IWebBrowser2 *iface, UINT iTInfo, LCID lcid,
  1262. LPTYPEINFO *ppTInfo)
  1263. {
  1264. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1265. TRACE("(%p)->(%d %d %p)\n", This, iTInfo, lcid, ppTInfo);
  1266. return get_typeinfo(IWebBrowser2_tid, ppTInfo);
  1267. }
  1268. static HRESULT WINAPI webbrowser_GetIDsOfNames(IWebBrowser2 *iface, REFIID riid,
  1269. LPOLESTR *rgszNames, UINT cNames,
  1270. LCID lcid, DISPID *rgDispId)
  1271. {
  1272. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1273. ITypeInfo *typeinfo;
  1274. HRESULT hr;
  1275. TRACE("(%p)->(%s %p %d %d %p)\n", This, debugstr_guid(riid), rgszNames, cNames,
  1276. lcid, rgDispId);
  1277. if(!rgszNames || cNames == 0 || !rgDispId)
  1278. return E_INVALIDARG;
  1279. hr = get_typeinfo(IWebBrowser2_tid, &typeinfo);
  1280. if (SUCCEEDED(hr))
  1281. {
  1282. hr = ITypeInfo_GetIDsOfNames(typeinfo, rgszNames, cNames, rgDispId);
  1283. ITypeInfo_Release(typeinfo);
  1284. }
  1285. return hr;
  1286. }
  1287. static HRESULT WINAPI webbrowser_Invoke(IWebBrowser2 *iface, DISPID dispIdMember,
  1288. REFIID riid, LCID lcid, WORD wFlags,
  1289. DISPPARAMS *pDispParams, VARIANT *pVarResult,
  1290. EXCEPINFO *pExcepInfo, UINT *puArgErr)
  1291. {
  1292. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1293. ITypeInfo *typeinfo;
  1294. HRESULT hr;
  1295. TRACE("(%p)->(%d %s %d %08x %p %p %p %p)\n", This, dispIdMember, debugstr_guid(riid),
  1296. lcid, wFlags, pDispParams, pVarResult, pExcepInfo, puArgErr);
  1297. hr = get_typeinfo(IWebBrowser2_tid, &typeinfo);
  1298. if (SUCCEEDED(hr))
  1299. {
  1300. hr = ITypeInfo_Invoke(typeinfo, &This->IWebBrowser2_iface, dispIdMember, wFlags,
  1301. pDispParams, pVarResult, pExcepInfo, puArgErr);
  1302. ITypeInfo_Release(typeinfo);
  1303. }
  1304. return hr;
  1305. }
  1306. /* IWebBrowser methods */
  1307. static HRESULT WINAPI webbrowser_GoBack(IWebBrowser2 *iface)
  1308. {
  1309. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1310. FIXME("(%p): stub\n", This);
  1311. return E_NOTIMPL;
  1312. }
  1313. static HRESULT WINAPI webbrowser_GoForward(IWebBrowser2 *iface)
  1314. {
  1315. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1316. FIXME("(%p): stub\n", This);
  1317. return E_NOTIMPL;
  1318. }
  1319. static HRESULT WINAPI webbrowser_GoHome(IWebBrowser2 *iface)
  1320. {
  1321. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1322. FIXME("(%p): stub\n", This);
  1323. return E_NOTIMPL;
  1324. }
  1325. static HRESULT WINAPI webbrowser_GoSearch(IWebBrowser2 *iface)
  1326. {
  1327. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1328. FIXME("(%p)\n", This);
  1329. return E_NOTIMPL;
  1330. }
  1331. static HRESULT WINAPI webbrowser_Navigate(IWebBrowser2 *iface, BSTR szUrl,
  1332. VARIANT *Flags, VARIANT *TargetFrameName,
  1333. VARIANT *PostData, VARIANT *Headers)
  1334. {
  1335. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1336. FIXME("(%p)->(%s %s %s %s %s): stub\n", This, debugstr_w(szUrl), debugstr_variant(Flags),
  1337. debugstr_variant(TargetFrameName), debugstr_variant(PostData),
  1338. debugstr_variant(Headers));
  1339. return E_NOTIMPL;
  1340. }
  1341. static HRESULT WINAPI webbrowser_Refresh(IWebBrowser2 *iface)
  1342. {
  1343. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1344. FIXME("(%p): stub\n", This);
  1345. return E_NOTIMPL;
  1346. }
  1347. static HRESULT WINAPI webbrowser_Refresh2(IWebBrowser2 *iface, VARIANT *Level)
  1348. {
  1349. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1350. FIXME("(%p)->(%s): stub\n", This, debugstr_variant(Level));
  1351. return E_NOTIMPL;
  1352. }
  1353. static HRESULT WINAPI webbrowser_Stop(IWebBrowser2 *iface)
  1354. {
  1355. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1356. FIXME("(%p): stub\n", This);
  1357. return E_NOTIMPL;
  1358. }
  1359. static HRESULT WINAPI webbrowser_get_Application(IWebBrowser2 *iface, IDispatch **ppDisp)
  1360. {
  1361. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1362. TRACE("(%p)->(%p)\n", This, ppDisp);
  1363. *ppDisp = (IDispatch*)iface;
  1364. IDispatch_AddRef(*ppDisp);
  1365. return S_OK;
  1366. }
  1367. static HRESULT WINAPI webbrowser_get_Parent(IWebBrowser2 *iface, IDispatch **ppDisp)
  1368. {
  1369. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1370. FIXME("(%p)->(%p)\n", This, ppDisp);
  1371. return E_NOTIMPL;
  1372. }
  1373. static HRESULT WINAPI webbrowser_get_Container(IWebBrowser2 *iface, IDispatch **ppDisp)
  1374. {
  1375. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1376. FIXME("(%p)->(%p)\n", This, ppDisp);
  1377. return E_NOTIMPL;
  1378. }
  1379. static HRESULT WINAPI webbrowser_get_Document(IWebBrowser2 *iface, IDispatch **ppDisp)
  1380. {
  1381. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1382. FIXME("(%p)->(%p)\n", This, ppDisp);
  1383. return E_NOTIMPL;
  1384. }
  1385. static HRESULT WINAPI webbrowser_get_TopLevelContainer(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
  1386. {
  1387. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1388. FIXME("(%p)->(%p)\n", This, pBool);
  1389. return E_NOTIMPL;
  1390. }
  1391. static HRESULT WINAPI webbrowser_get_Type(IWebBrowser2 *iface, BSTR *Type)
  1392. {
  1393. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1394. FIXME("(%p)->(%p)\n", This, Type);
  1395. return E_NOTIMPL;
  1396. }
  1397. static HRESULT WINAPI webbrowser_get_Left(IWebBrowser2 *iface, LONG *pl)
  1398. {
  1399. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1400. FIXME("(%p)->(%p)\n", This, pl);
  1401. return E_NOTIMPL;
  1402. }
  1403. static HRESULT WINAPI webbrowser_put_Left(IWebBrowser2 *iface, LONG Left)
  1404. {
  1405. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1406. FIXME("(%p)->(%d)\n", This, Left);
  1407. return E_NOTIMPL;
  1408. }
  1409. static HRESULT WINAPI webbrowser_get_Top(IWebBrowser2 *iface, LONG *pl)
  1410. {
  1411. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1412. FIXME("(%p)->(%p)\n", This, pl);
  1413. return E_NOTIMPL;
  1414. }
  1415. static HRESULT WINAPI webbrowser_put_Top(IWebBrowser2 *iface, LONG Top)
  1416. {
  1417. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1418. FIXME("(%p)->(%d)\n", This, Top);
  1419. return E_NOTIMPL;
  1420. }
  1421. static HRESULT WINAPI webbrowser_get_Width(IWebBrowser2 *iface, LONG *pl)
  1422. {
  1423. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1424. FIXME("(%p)->(%p)\n", This, pl);
  1425. return E_NOTIMPL;
  1426. }
  1427. static HRESULT WINAPI webbrowser_put_Width(IWebBrowser2 *iface, LONG Width)
  1428. {
  1429. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1430. FIXME("(%p)->(%d)\n", This, Width);
  1431. return E_NOTIMPL;
  1432. }
  1433. static HRESULT WINAPI webbrowser_get_Height(IWebBrowser2 *iface, LONG *pl)
  1434. {
  1435. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1436. FIXME("(%p)->(%p)\n", This, pl);
  1437. return E_NOTIMPL;
  1438. }
  1439. static HRESULT WINAPI webbrowser_put_Height(IWebBrowser2 *iface, LONG Height)
  1440. {
  1441. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1442. FIXME("(%p)->(%d)\n", This, Height);
  1443. return E_NOTIMPL;
  1444. }
  1445. static HRESULT WINAPI webbrowser_get_LocationName(IWebBrowser2 *iface, BSTR *LocationName)
  1446. {
  1447. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1448. FIXME("(%p)->(%p)\n", This, LocationName);
  1449. return E_NOTIMPL;
  1450. }
  1451. static HRESULT WINAPI webbrowser_get_LocationURL(IWebBrowser2 *iface, BSTR *LocationURL)
  1452. {
  1453. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1454. FIXME("(%p)->(%p)\n", This, LocationURL);
  1455. return E_NOTIMPL;
  1456. }
  1457. static HRESULT WINAPI webbrowser_get_Busy(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
  1458. {
  1459. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1460. FIXME("(%p)->(%p)\n", This, pBool);
  1461. return E_NOTIMPL;
  1462. }
  1463. static HRESULT WINAPI webbrowser_Quit(IWebBrowser2 *iface)
  1464. {
  1465. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1466. FIXME("(%p)\n", This);
  1467. return E_NOTIMPL;
  1468. }
  1469. static HRESULT WINAPI webbrowser_ClientToWindow(IWebBrowser2 *iface, int *pcx, int *pcy)
  1470. {
  1471. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1472. FIXME("(%p)->(%p %p)\n", This, pcx, pcy);
  1473. return E_NOTIMPL;
  1474. }
  1475. static HRESULT WINAPI webbrowser_PutProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT vtValue)
  1476. {
  1477. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1478. FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(&vtValue));
  1479. return E_NOTIMPL;
  1480. }
  1481. static HRESULT WINAPI webbrowser_GetProperty(IWebBrowser2 *iface, BSTR szProperty, VARIANT *pvtValue)
  1482. {
  1483. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1484. FIXME("(%p)->(%s %s)\n", This, debugstr_w(szProperty), debugstr_variant(pvtValue));
  1485. return E_NOTIMPL;
  1486. }
  1487. static HRESULT WINAPI webbrowser_get_Name(IWebBrowser2 *iface, BSTR *Name)
  1488. {
  1489. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1490. FIXME("(%p)->(%p)\n", This, Name);
  1491. return E_NOTIMPL;
  1492. }
  1493. static HRESULT WINAPI webbrowser_get_HWND(IWebBrowser2 *iface, SHANDLE_PTR *pHWND)
  1494. {
  1495. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1496. FIXME("(%p)->(%p)\n", This, pHWND);
  1497. return E_NOTIMPL;
  1498. }
  1499. static HRESULT WINAPI webbrowser_get_FullName(IWebBrowser2 *iface, BSTR *FullName)
  1500. {
  1501. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1502. FIXME("(%p)->(%p)\n", This, FullName);
  1503. return E_NOTIMPL;
  1504. }
  1505. static HRESULT WINAPI webbrowser_get_Path(IWebBrowser2 *iface, BSTR *Path)
  1506. {
  1507. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1508. FIXME("(%p)->(%p)\n", This, Path);
  1509. return E_NOTIMPL;
  1510. }
  1511. static HRESULT WINAPI webbrowser_get_Visible(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
  1512. {
  1513. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1514. FIXME("(%p)->(%p)\n", This, pBool);
  1515. return E_NOTIMPL;
  1516. }
  1517. static HRESULT WINAPI webbrowser_put_Visible(IWebBrowser2 *iface, VARIANT_BOOL Value)
  1518. {
  1519. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1520. FIXME("(%p)->(%x)\n", This, Value);
  1521. return E_NOTIMPL;
  1522. }
  1523. static HRESULT WINAPI webbrowser_get_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL *pBool)
  1524. {
  1525. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1526. FIXME("(%p)->(%p)\n", This, pBool);
  1527. return E_NOTIMPL;
  1528. }
  1529. static HRESULT WINAPI webbrowser_put_StatusBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
  1530. {
  1531. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1532. FIXME("(%p)->(%x)\n", This, Value);
  1533. return E_NOTIMPL;
  1534. }
  1535. static HRESULT WINAPI webbrowser_get_StatusText(IWebBrowser2 *iface, BSTR *StatusText)
  1536. {
  1537. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1538. FIXME("(%p)->(%p)\n", This, StatusText);
  1539. return E_NOTIMPL;
  1540. }
  1541. static HRESULT WINAPI webbrowser_put_StatusText(IWebBrowser2 *iface, BSTR StatusText)
  1542. {
  1543. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1544. FIXME("(%p)->(%s)\n", This, debugstr_w(StatusText));
  1545. return E_NOTIMPL;
  1546. }
  1547. static HRESULT WINAPI webbrowser_get_ToolBar(IWebBrowser2 *iface, int *Value)
  1548. {
  1549. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1550. FIXME("(%p)->(%p)\n", This, Value);
  1551. return E_NOTIMPL;
  1552. }
  1553. static HRESULT WINAPI webbrowser_put_ToolBar(IWebBrowser2 *iface, int Value)
  1554. {
  1555. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1556. FIXME("(%p)->(%x)\n", This, Value);
  1557. return E_NOTIMPL;
  1558. }
  1559. static HRESULT WINAPI webbrowser_get_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
  1560. {
  1561. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1562. FIXME("(%p)->(%p)\n", This, Value);
  1563. return E_NOTIMPL;
  1564. }
  1565. static HRESULT WINAPI webbrowser_put_MenuBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
  1566. {
  1567. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1568. FIXME("(%p)->(%x)\n", This, Value);
  1569. return E_NOTIMPL;
  1570. }
  1571. static HRESULT WINAPI webbrowser_get_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL *pbFullScreen)
  1572. {
  1573. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1574. FIXME("(%p)->(%p)\n", This, pbFullScreen);
  1575. return E_NOTIMPL;
  1576. }
  1577. static HRESULT WINAPI webbrowser_put_FullScreen(IWebBrowser2 *iface, VARIANT_BOOL bFullScreen)
  1578. {
  1579. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1580. FIXME("(%p)->(%x)\n", This, bFullScreen);
  1581. return E_NOTIMPL;
  1582. }
  1583. static HRESULT WINAPI webbrowser_Navigate2(IWebBrowser2 *iface, VARIANT *URL, VARIANT *Flags,
  1584. VARIANT *TargetFrameName, VARIANT *PostData, VARIANT *Headers)
  1585. {
  1586. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1587. FIXME("(%p)->(%s %s %s %s %s)\n", This, debugstr_variant(URL), debugstr_variant(Flags),
  1588. debugstr_variant(TargetFrameName), debugstr_variant(PostData), debugstr_variant(Headers));
  1589. return E_NOTIMPL;
  1590. }
  1591. static HRESULT WINAPI webbrowser_QueryStatusWB(IWebBrowser2 *iface, OLECMDID cmdID, OLECMDF *pcmdf)
  1592. {
  1593. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1594. FIXME("(%p)->(%d %p)\n", This, cmdID, pcmdf);
  1595. return E_NOTIMPL;
  1596. }
  1597. static HRESULT WINAPI webbrowser_ExecWB(IWebBrowser2 *iface, OLECMDID cmdID,
  1598. OLECMDEXECOPT cmdexecopt, VARIANT *pvaIn, VARIANT *pvaOut)
  1599. {
  1600. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1601. FIXME("(%p)->(%d %d %s %p)\n", This, cmdID, cmdexecopt, debugstr_variant(pvaIn), pvaOut);
  1602. return E_NOTIMPL;
  1603. }
  1604. static HRESULT WINAPI webbrowser_ShowBrowserBar(IWebBrowser2 *iface, VARIANT *pvaClsid,
  1605. VARIANT *pvarShow, VARIANT *pvarSize)
  1606. {
  1607. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1608. FIXME("(%p)->(%s %s %s)\n", This, debugstr_variant(pvaClsid), debugstr_variant(pvarShow),
  1609. debugstr_variant(pvarSize));
  1610. return E_NOTIMPL;
  1611. }
  1612. static HRESULT WINAPI webbrowser_get_ReadyState(IWebBrowser2 *iface, READYSTATE *lpReadyState)
  1613. {
  1614. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1615. FIXME("(%p)->(%p)\n", This, lpReadyState);
  1616. return E_NOTIMPL;
  1617. }
  1618. static HRESULT WINAPI webbrowser_get_Offline(IWebBrowser2 *iface, VARIANT_BOOL *pbOffline)
  1619. {
  1620. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1621. FIXME("(%p)->(%p)\n", This, pbOffline);
  1622. return E_NOTIMPL;
  1623. }
  1624. static HRESULT WINAPI webbrowser_put_Offline(IWebBrowser2 *iface, VARIANT_BOOL bOffline)
  1625. {
  1626. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1627. FIXME("(%p)->(%x)\n", This, bOffline);
  1628. return E_NOTIMPL;
  1629. }
  1630. static HRESULT WINAPI webbrowser_get_Silent(IWebBrowser2 *iface, VARIANT_BOOL *pbSilent)
  1631. {
  1632. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1633. FIXME("(%p)->(%p)\n", This, pbSilent);
  1634. return E_NOTIMPL;
  1635. }
  1636. static HRESULT WINAPI webbrowser_put_Silent(IWebBrowser2 *iface, VARIANT_BOOL bSilent)
  1637. {
  1638. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1639. FIXME("(%p)->(%x)\n", This, bSilent);
  1640. return E_NOTIMPL;
  1641. }
  1642. static HRESULT WINAPI webbrowser_get_RegisterAsBrowser(IWebBrowser2 *iface,
  1643. VARIANT_BOOL *pbRegister)
  1644. {
  1645. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1646. FIXME("(%p)->(%p)\n", This, pbRegister);
  1647. return E_NOTIMPL;
  1648. }
  1649. static HRESULT WINAPI webbrowser_put_RegisterAsBrowser(IWebBrowser2 *iface,
  1650. VARIANT_BOOL bRegister)
  1651. {
  1652. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1653. FIXME("(%p)->(%x)\n", This, bRegister);
  1654. return E_NOTIMPL;
  1655. }
  1656. static HRESULT WINAPI webbrowser_get_RegisterAsDropTarget(IWebBrowser2 *iface,
  1657. VARIANT_BOOL *pbRegister)
  1658. {
  1659. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1660. FIXME("(%p)->(%p)\n", This, pbRegister);
  1661. return E_NOTIMPL;
  1662. }
  1663. static HRESULT WINAPI webbrowser_put_RegisterAsDropTarget(IWebBrowser2 *iface,
  1664. VARIANT_BOOL bRegister)
  1665. {
  1666. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1667. FIXME("(%p)->(%x)\n", This, bRegister);
  1668. return E_NOTIMPL;
  1669. }
  1670. static HRESULT WINAPI webbrowser_get_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL *pbRegister)
  1671. {
  1672. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1673. FIXME("(%p)->(%p)\n", This, pbRegister);
  1674. return E_NOTIMPL;
  1675. }
  1676. static HRESULT WINAPI webbrowser_put_TheaterMode(IWebBrowser2 *iface, VARIANT_BOOL bRegister)
  1677. {
  1678. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1679. TRACE("(%p)->(%x)\n", This, bRegister);
  1680. return E_NOTIMPL;
  1681. }
  1682. static HRESULT WINAPI webbrowser_get_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL *Value)
  1683. {
  1684. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1685. FIXME("(%p)->(%p)\n", This, Value);
  1686. return E_NOTIMPL;
  1687. }
  1688. static HRESULT WINAPI webbrowser_put_AddressBar(IWebBrowser2 *iface, VARIANT_BOOL Value)
  1689. {
  1690. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1691. FIXME("(%p)->(%x)\n", This, Value);
  1692. return E_NOTIMPL;
  1693. }
  1694. static HRESULT WINAPI webbrowser_get_Resizable(IWebBrowser2 *iface, VARIANT_BOOL *Value)
  1695. {
  1696. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1697. FIXME("(%p)->(%p)\n", This, Value);
  1698. return E_NOTIMPL;
  1699. }
  1700. static HRESULT WINAPI webbrowser_put_Resizable(IWebBrowser2 *iface, VARIANT_BOOL Value)
  1701. {
  1702. struct shellbrowserwindow *This = impl_from_IWebBrowser2(iface);
  1703. FIXME("(%p)->(%x)\n", This, Value);
  1704. return E_NOTIMPL;
  1705. }
  1706. static const IWebBrowser2Vtbl webbrowser2vtbl =
  1707. {
  1708. webbrowser_QueryInterface,
  1709. webbrowser_AddRef,
  1710. webbrowser_Release,
  1711. webbrowser_GetTypeInfoCount,
  1712. webbrowser_GetTypeInfo,
  1713. webbrowser_GetIDsOfNames,
  1714. webbrowser_Invoke,
  1715. webbrowser_GoBack,
  1716. webbrowser_GoForward,
  1717. webbrowser_GoHome,
  1718. webbrowser_GoSearch,
  1719. webbrowser_Navigate,
  1720. webbrowser_Refresh,
  1721. webbrowser_Refresh2,
  1722. webbrowser_Stop,
  1723. webbrowser_get_Application,
  1724. webbrowser_get_Parent,
  1725. webbrowser_get_Container,
  1726. webbrowser_get_Document,
  1727. webbrowser_get_TopLevelContainer,
  1728. webbrowser_get_Type,
  1729. webbrowser_get_Left,
  1730. webbrowser_put_Left,
  1731. webbrowser_get_Top,
  1732. webbrowser_put_Top,
  1733. webbrowser_get_Width,
  1734. webbrowser_put_Width,
  1735. webbrowser_get_Height,
  1736. webbrowser_put_Height,
  1737. webbrowser_get_LocationName,
  1738. webbrowser_get_LocationURL,
  1739. webbrowser_get_Busy,
  1740. webbrowser_Quit,
  1741. webbrowser_ClientToWindow,
  1742. webbrowser_PutProperty,
  1743. webbrowser_GetProperty,
  1744. webbrowser_get_Name,
  1745. webbrowser_get_HWND,
  1746. webbrowser_get_FullName,
  1747. webbrowser_get_Path,
  1748. webbrowser_get_Visible,
  1749. webbrowser_put_Visible,
  1750. webbrowser_get_StatusBar,
  1751. webbrowser_put_StatusBar,
  1752. webbrowser_get_StatusText,
  1753. webbrowser_put_StatusText,
  1754. webbrowser_get_ToolBar,
  1755. webbrowser_put_ToolBar,
  1756. webbrowser_get_MenuBar,
  1757. webbrowser_put_MenuBar,
  1758. webbrowser_get_FullScreen,
  1759. webbrowser_put_FullScreen,
  1760. webbrowser_Navigate2,
  1761. webbrowser_QueryStatusWB,
  1762. webbrowser_ExecWB,
  1763. webbrowser_ShowBrowserBar,
  1764. webbrowser_get_ReadyState,
  1765. webbrowser_get_Offline,
  1766. webbrowser_put_Offline,
  1767. webbrowser_get_Silent,
  1768. webbrowser_put_Silent,
  1769. webbrowser_get_RegisterAsBrowser,
  1770. webbrowser_put_RegisterAsBrowser,
  1771. webbrowser_get_RegisterAsDropTarget,
  1772. webbrowser_put_RegisterAsDropTarget,
  1773. webbrowser_get_TheaterMode,
  1774. webbrowser_put_TheaterMode,
  1775. webbrowser_get_AddressBar,
  1776. webbrowser_put_AddressBar,
  1777. webbrowser_get_Resizable,
  1778. webbrowser_put_Resizable
  1779. };
  1780. static HRESULT WINAPI serviceprovider_QueryInterface(IServiceProvider *iface, REFIID riid, void **ppv)
  1781. {
  1782. struct shellbrowserwindow *This = impl_from_IServiceProvider(iface);
  1783. return IWebBrowser2_QueryInterface(&This->IWebBrowser2_iface, riid, ppv);
  1784. }
  1785. static ULONG WINAPI serviceprovider_AddRef(IServiceProvider *iface)
  1786. {
  1787. struct shellbrowserwindow *This = impl_from_IServiceProvider(iface);
  1788. return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
  1789. }
  1790. static ULONG WINAPI serviceprovider_Release(IServiceProvider *iface)
  1791. {
  1792. struct shellbrowserwindow *This = impl_from_IServiceProvider(iface);
  1793. return IWebBrowser2_Release(&This->IWebBrowser2_iface);
  1794. }
  1795. static HRESULT WINAPI serviceprovider_QueryService(IServiceProvider *iface, REFGUID service,
  1796. REFIID riid, void **ppv)
  1797. {
  1798. struct shellbrowserwindow *This = impl_from_IServiceProvider(iface);
  1799. TRACE("%s %s %p\n", debugstr_guid(service), debugstr_guid(riid), ppv);
  1800. if (IsEqualGUID(service, &SID_STopLevelBrowser))
  1801. return IShellBrowser_QueryInterface(&This->IShellBrowser_iface, riid, ppv);
  1802. WARN("unknown service id %s\n", debugstr_guid(service));
  1803. return E_NOTIMPL;
  1804. }
  1805. static const IServiceProviderVtbl serviceprovidervtbl =
  1806. {
  1807. serviceprovider_QueryInterface,
  1808. serviceprovider_AddRef,
  1809. serviceprovider_Release,
  1810. serviceprovider_QueryService
  1811. };
  1812. /* IShellBrowser */
  1813. static HRESULT WINAPI shellbrowser_QueryInterface(IShellBrowser *iface, REFIID riid, void **ppv)
  1814. {
  1815. TRACE("%s %p\n", debugstr_guid(riid), ppv);
  1816. *ppv = NULL;
  1817. if (IsEqualGUID(&IID_IShellBrowser, riid) ||
  1818. IsEqualGUID(&IID_IOleWindow, riid) ||
  1819. IsEqualGUID(&IID_IUnknown, riid))
  1820. {
  1821. *ppv = iface;
  1822. }
  1823. if (*ppv)
  1824. {
  1825. IUnknown_AddRef((IUnknown*)*ppv);
  1826. return S_OK;
  1827. }
  1828. return E_NOINTERFACE;
  1829. }
  1830. static ULONG WINAPI shellbrowser_AddRef(IShellBrowser *iface)
  1831. {
  1832. struct shellbrowserwindow *This = impl_from_IShellBrowser(iface);
  1833. return IWebBrowser2_AddRef(&This->IWebBrowser2_iface);
  1834. }
  1835. static ULONG WINAPI shellbrowser_Release(IShellBrowser *iface)
  1836. {
  1837. struct shellbrowserwindow *This = impl_from_IShellBrowser(iface);
  1838. return IWebBrowser2_Release(&This->IWebBrowser2_iface);
  1839. }
  1840. static HRESULT WINAPI shellbrowser_GetWindow(IShellBrowser *iface, HWND *phwnd)
  1841. {
  1842. FIXME("%p\n", phwnd);
  1843. return E_NOTIMPL;
  1844. }
  1845. static HRESULT WINAPI shellbrowser_ContextSensitiveHelp(IShellBrowser *iface, BOOL mode)
  1846. {
  1847. FIXME("%d\n", mode);
  1848. return E_NOTIMPL;
  1849. }
  1850. static HRESULT WINAPI shellbrowser_InsertMenusSB(IShellBrowser *iface, HMENU hmenuShared,
  1851. OLEMENUGROUPWIDTHS *menuwidths)
  1852. {
  1853. FIXME("%p %p\n", hmenuShared, menuwidths);
  1854. return E_NOTIMPL;
  1855. }
  1856. static HRESULT WINAPI shellbrowser_SetMenuSB(IShellBrowser *iface, HMENU hmenuShared,
  1857. HOLEMENU holemenuReserved, HWND hwndActiveObject)
  1858. {
  1859. FIXME("%p %p %p\n", hmenuShared, holemenuReserved, hwndActiveObject);
  1860. return E_NOTIMPL;
  1861. }
  1862. static HRESULT WINAPI shellbrowser_RemoveMenusSB(IShellBrowser *iface, HMENU hmenuShared)
  1863. {
  1864. FIXME("%p\n", hmenuShared);
  1865. return E_NOTIMPL;
  1866. }
  1867. static HRESULT WINAPI shellbrowser_SetStatusTextSB(IShellBrowser *iface, LPCOLESTR text)
  1868. {
  1869. FIXME("%s\n", debugstr_w(text));
  1870. return E_NOTIMPL;
  1871. }
  1872. static HRESULT WINAPI shellbrowser_EnableModelessSB(IShellBrowser *iface, BOOL enable)
  1873. {
  1874. FIXME("%d\n", enable);
  1875. return E_NOTIMPL;
  1876. }
  1877. static HRESULT WINAPI shellbrowser_TranslateAcceleratorSB(IShellBrowser *iface, MSG *pmsg, WORD wID)
  1878. {
  1879. FIXME("%p 0x%x\n", pmsg, wID);
  1880. return E_NOTIMPL;
  1881. }
  1882. static HRESULT WINAPI shellbrowser_BrowseObject(IShellBrowser *iface, LPCITEMIDLIST pidl, UINT flags)
  1883. {
  1884. FIXME("%p %x\n", pidl, flags);
  1885. return E_NOTIMPL;
  1886. }
  1887. static HRESULT WINAPI shellbrowser_GetViewStateStream(IShellBrowser *iface, DWORD mode, IStream **stream)
  1888. {
  1889. FIXME("0x%x %p\n", mode, stream);
  1890. return E_NOTIMPL;
  1891. }
  1892. static HRESULT WINAPI shellbrowser_GetControlWindow(IShellBrowser *iface, UINT id, HWND *phwnd)
  1893. {
  1894. FIXME("%d %p\n", id, phwnd);
  1895. return E_NOTIMPL;
  1896. }
  1897. static HRESULT WINAPI shellbrowser_SendControlMsg(IShellBrowser *iface, UINT id, UINT uMsg,
  1898. WPARAM wParam, LPARAM lParam, LRESULT *pret)
  1899. {
  1900. FIXME("%d %d %lx %lx %p\n", id, uMsg, wParam, lParam, pret);
  1901. return E_NOTIMPL;
  1902. }
  1903. static HRESULT WINAPI shellbrowser_QueryActiveShellView(IShellBrowser *iface, IShellView **view)
  1904. {
  1905. TRACE("%p\n", view);
  1906. *view = desktopshellbrowserwindow.view;
  1907. IShellView_AddRef(*view);
  1908. return S_OK;
  1909. }
  1910. static HRESULT WINAPI shellbrowser_OnViewWindowActive(IShellBrowser *iface, IShellView *view)
  1911. {
  1912. FIXME("%p\n", view);
  1913. return E_NOTIMPL;
  1914. }
  1915. static HRESULT WINAPI shellbrowser_SetToolbarItems(IShellBrowser *iface, LPTBBUTTONSB buttons,
  1916. UINT count, UINT flags)
  1917. {
  1918. FIXME("%p %d 0x%x\n", buttons, count, flags);
  1919. return E_NOTIMPL;
  1920. }
  1921. static const IShellBrowserVtbl shellbrowservtbl = {
  1922. shellbrowser_QueryInterface,
  1923. shellbrowser_AddRef,
  1924. shellbrowser_Release,
  1925. shellbrowser_GetWindow,
  1926. shellbrowser_ContextSensitiveHelp,
  1927. shellbrowser_InsertMenusSB,
  1928. shellbrowser_SetMenuSB,
  1929. shellbrowser_RemoveMenusSB,
  1930. shellbrowser_SetStatusTextSB,
  1931. shellbrowser_EnableModelessSB,
  1932. shellbrowser_TranslateAcceleratorSB,
  1933. shellbrowser_BrowseObject,
  1934. shellbrowser_GetViewStateStream,
  1935. shellbrowser_GetControlWindow,
  1936. shellbrowser_SendControlMsg,
  1937. shellbrowser_QueryActiveShellView,
  1938. shellbrowser_OnViewWindowActive,
  1939. shellbrowser_SetToolbarItems
  1940. };
  1941. static void desktopshellbrowserwindow_init(void)
  1942. {
  1943. IShellFolder *folder;
  1944. desktopshellbrowserwindow.IWebBrowser2_iface.lpVtbl = &webbrowser2vtbl;
  1945. desktopshellbrowserwindow.IServiceProvider_iface.lpVtbl = &serviceprovidervtbl;
  1946. desktopshellbrowserwindow.IShellBrowser_iface.lpVtbl = &shellbrowservtbl;
  1947. if (FAILED(SHGetDesktopFolder(&folder)))
  1948. return;
  1949. IShellFolder_CreateViewObject(folder, NULL, &IID_IShellView, (void**)&desktopshellbrowserwindow.view);
  1950. }
  1951. static void shellwindows_init(void)
  1952. {
  1953. HRESULT hr;
  1954. CoInitialize(NULL);
  1955. shellwindows.IShellWindows_iface.lpVtbl = &shellwindowsvtbl;
  1956. InitializeCriticalSection(&shellwindows.cs);
  1957. shellwindows.cs.DebugInfo->Spare[0] = (DWORD_PTR)(__FILE__ ": shellwindows.cs");
  1958. hr = CoRegisterClassObject(&CLSID_ShellWindows,
  1959. (IUnknown*)&shellwindows_classfactory.IClassFactory_iface,
  1960. CLSCTX_LOCAL_SERVER,
  1961. REGCLS_MULTIPLEUSE,
  1962. &shellwindows_classfactory.classreg);
  1963. if (FAILED(hr))
  1964. WARN("Failed to register ShellWindows object: %08x\n", hr);
  1965. }