Fixed a few prototypes in the USER driver.
[wine] / dlls / mshtml / tests / htmldoc.c
1 /*
2  * Copyright 2005 Jacek Caban
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
17  */
18
19 #define COBJMACROS
20
21 #include <wine/test.h>
22 #include <stdarg.h>
23
24 #include "windef.h"
25 #include "winbase.h"
26 #include "ole2.h"
27 #include "mshtml.h"
28 #include "docobj.h"
29 #include "mshtmhst.h"
30
31 #define DEFINE_EXPECT(func) \
32     static BOOL expect_ ## func = FALSE, called_ ## func = FALSE
33
34 #define SET_EXPECT(func) \
35     expect_ ## func = TRUE
36
37 #define CHECK_EXPECT(func) \
38     ok(expect_ ##func, "unexpected call\n"); \
39     expect_ ## func = FALSE; \
40     called_ ## func = TRUE
41
42 #define CHECK_CALLED(func) \
43     ok(called_ ## func, "expected " #func "\n"); \
44     expect_ ## func = called_ ## func = FALSE
45
46 static IUnknown *htmldoc_unk = NULL;
47 static IOleDocumentView *view = NULL;
48 static HWND container_hwnd = NULL, hwnd = NULL, last_hwnd = NULL;
49
50 DEFINE_EXPECT(LockContainer);
51 DEFINE_EXPECT(SetActiveObject);
52 DEFINE_EXPECT(GetWindow);
53 DEFINE_EXPECT(CanInPlaceActivate);
54 DEFINE_EXPECT(OnInPlaceActivate);
55 DEFINE_EXPECT(OnUIActivate);
56 DEFINE_EXPECT(GetWindowContext);
57 DEFINE_EXPECT(OnUIDeactivate);
58 DEFINE_EXPECT(OnInPlaceDeactivate);
59 DEFINE_EXPECT(GetContainer);
60 DEFINE_EXPECT(ShowUI);
61 DEFINE_EXPECT(ActivateMe);
62 DEFINE_EXPECT(GetHostInfo);
63 DEFINE_EXPECT(HideUI);
64 DEFINE_EXPECT(GetOptionKeyPath);
65 DEFINE_EXPECT(GetOverrideKeyPath);
66
67 static BOOL expect_LockContainer_fLock;
68 static BOOL expect_SetActiveObject_active;
69
70 static HRESULT QueryInterface(REFIID riid, void **ppv);
71
72 static HRESULT WINAPI OleContainer_QueryInterface(IOleContainer *iface, REFIID riid, void **ppv)
73 {
74     return QueryInterface(riid, ppv);
75 }
76
77 static ULONG WINAPI OleContainer_AddRef(IOleContainer *iface)
78 {
79     return 2;
80 }
81
82 static ULONG WINAPI OleContainer_Release(IOleContainer *iface)
83 {
84     return 1;
85 }
86
87 static HRESULT WINAPI OleContainer_ParseDisplayName(IOleContainer *iface, IBindCtx *pbc,
88         LPOLESTR pszDiaplayName, ULONG *pchEaten, IMoniker **ppmkOut)
89 {
90     ok(0, "unexpected call\n");
91     return E_NOTIMPL;
92 }
93
94 static HRESULT WINAPI OleContainer_EnumObjects(IOleContainer *iface, DWORD grfFlags,
95         IEnumUnknown **ppenum)
96 {
97     ok(0, "unexpected call\n");
98     return E_NOTIMPL;
99 }
100
101 static HRESULT WINAPI OleContainer_LockContainer(IOleContainer *iface, BOOL fLock)
102 {
103     CHECK_EXPECT(LockContainer);
104     ok(expect_LockContainer_fLock == fLock, "fLock=%x, expected %x\n", fLock, expect_LockContainer_fLock);
105     return S_OK;
106 }
107
108 static const IOleContainerVtbl OleContainerVtbl = {
109     OleContainer_QueryInterface,
110     OleContainer_AddRef,
111     OleContainer_Release,
112     OleContainer_ParseDisplayName,
113     OleContainer_EnumObjects,
114     OleContainer_LockContainer
115 };
116
117 static IOleContainer OleContainer = { &OleContainerVtbl };
118
119 static HRESULT WINAPI InPlaceFrame_QueryInterface(IOleInPlaceFrame *iface, REFIID riid, void **ppv)
120 {
121     return QueryInterface(riid, ppv);
122 }
123
124 static ULONG WINAPI InPlaceFrame_AddRef(IOleInPlaceFrame *iface)
125 {
126     return 2;
127 }
128
129 static ULONG WINAPI InPlaceFrame_Release(IOleInPlaceFrame *iface)
130 {
131     return 1;
132 }
133
134 static HRESULT WINAPI InPlaceFrame_GetWindow(IOleInPlaceFrame *iface, HWND *phwnd)
135 {
136     ok(0, "unexpected call\n");
137     return E_NOTIMPL;
138 }
139
140 static HRESULT WINAPI InPlaceFrame_ContextSensitiveHelp(IOleInPlaceFrame *iface, BOOL fEnterMode)
141 {
142     ok(0, "unexpected call\n");
143     return E_NOTIMPL;
144 }
145
146 static HRESULT WINAPI InPlaceFrame_GetBorder(IOleInPlaceFrame *iface, LPRECT lprectBorder)
147 {
148     ok(0, "unexpected call\n");
149     return E_NOTIMPL;
150 }
151
152 static HRESULT WINAPI InPlaceFrame_RequestBorderSpace(IOleInPlaceFrame *iface,
153         LPCBORDERWIDTHS pborderwidths)
154 {
155     ok(0, "unexpected call\n");
156     return E_NOTIMPL;
157 }
158
159 static HRESULT WINAPI InPlaceFrame_SetBorderSpace(IOleInPlaceFrame *iface,
160         LPCBORDERWIDTHS pborderwidths)
161 {
162     ok(0, "unexpected call\n");
163     return E_NOTIMPL;
164 }
165
166 static HRESULT WINAPI InPlaceFrame_SetActiveObject(IOleInPlaceFrame *iface,
167         IOleInPlaceActiveObject *pActiveObject, LPCOLESTR pszObjName)
168 {
169     static const WCHAR wszHTML_Document[] =
170         {'H','T','M','L',' ','D','o','c','u','m','e','n','t',0};
171
172     ok(expect_SetActiveObject, "unexpected call\n");
173     called_SetActiveObject = TRUE;
174
175     if(expect_SetActiveObject_active) {
176         ok(pActiveObject != NULL, "pActiveObject = NULL\n");
177         ok(!lstrcmpW(wszHTML_Document, pszObjName), "pszObjName != \"HTML Document\"\n");
178     }else {
179         ok(pActiveObject == NULL, "pActiveObject=%p, expected NULL\n", pActiveObject);
180         ok(pszObjName == NULL, "pszObjName=%p, expected NULL\n", pszObjName);
181     }
182
183     return S_OK;
184 }
185
186 static HRESULT WINAPI InPlaceFrame_InsertMenus(IOleInPlaceFrame *iface, HMENU hmenuShared,
187         LPOLEMENUGROUPWIDTHS lpMenuWidths)
188 {
189     ok(0, "unexpected call\n");
190     return E_NOTIMPL;
191 }
192
193 static HRESULT WINAPI InPlaceFrame_SetMenu(IOleInPlaceFrame *iface, HMENU hmenuShared,
194         HOLEMENU holemenu, HWND hwndActiveObject)
195 {
196     ok(0, "unexpected call\n");
197     return E_NOTIMPL;
198 }
199
200 static HRESULT WINAPI InPlaceFrame_RemoveMenus(IOleInPlaceFrame *iface, HMENU hmenuShared)
201 {
202     ok(0, "unexpected call\n");
203     return E_NOTIMPL;
204 }
205
206 static HRESULT WINAPI InPlaceFrame_SetStatusText(IOleInPlaceFrame *iface, LPCOLESTR pszStatusText)
207 {
208     ok(0, "unexpected call\n");
209     return E_NOTIMPL;
210 }
211
212 static HRESULT WINAPI InPlaceFrame_EnableModeless(IOleInPlaceFrame *iface, BOOL fEnable)
213 {
214     ok(0, "unexpected call\n");
215     return E_NOTIMPL;
216 }
217
218 static HRESULT WINAPI InPlaceFrame_TranslateAccelerator(IOleInPlaceFrame *iface, LPMSG lpmsg, WORD wID)
219 {
220     ok(0, "unexpected call\n");
221     return E_NOTIMPL;
222 }
223
224 static const IOleInPlaceFrameVtbl InPlaceFrameVtbl = {
225     InPlaceFrame_QueryInterface,
226     InPlaceFrame_AddRef,
227     InPlaceFrame_Release,
228     InPlaceFrame_GetWindow,
229     InPlaceFrame_ContextSensitiveHelp,
230     InPlaceFrame_GetBorder,
231     InPlaceFrame_RequestBorderSpace,
232     InPlaceFrame_SetBorderSpace,
233     InPlaceFrame_SetActiveObject,
234     InPlaceFrame_InsertMenus,
235     InPlaceFrame_SetMenu,
236     InPlaceFrame_RemoveMenus,
237     InPlaceFrame_SetStatusText,
238     InPlaceFrame_EnableModeless,
239     InPlaceFrame_TranslateAccelerator
240 };
241
242 static IOleInPlaceFrame InPlaceFrame = { &InPlaceFrameVtbl };
243
244 static HRESULT WINAPI InPlaceSite_QueryInterface(IOleInPlaceSite *iface, REFIID riid, void **ppv)
245 {
246     return QueryInterface(riid, ppv);
247 }
248
249 static ULONG WINAPI InPlaceSite_AddRef(IOleInPlaceSite *iface)
250 {
251     return 2;
252 }
253
254 static ULONG WINAPI InPlaceSite_Release(IOleInPlaceSite *iface)
255 {
256     return 1;
257 }
258
259 static HRESULT WINAPI InPlaceSite_GetWindow(IOleInPlaceSite *iface, HWND *phwnd)
260 {
261     CHECK_EXPECT(GetWindow);
262     ok(phwnd != NULL, "phwnd = NULL\n");
263     *phwnd = container_hwnd;
264     return S_OK;
265 }
266
267 static HRESULT WINAPI InPlaceSite_ContextSensitiveHelp(IOleInPlaceSite *iface, BOOL fEnterMode)
268 {
269     ok(0, "unexpected call\n");
270     return E_NOTIMPL;
271 }
272
273 static HRESULT WINAPI InPlaceSite_CanInPlaceActivate(IOleInPlaceSite *iface)
274 {
275     CHECK_EXPECT(CanInPlaceActivate);
276     return S_OK;
277 }
278
279 static HRESULT WINAPI InPlaceSite_OnInPlaceActivate(IOleInPlaceSite *iface)
280 {
281     CHECK_EXPECT(OnInPlaceActivate);
282     return S_OK;
283 }
284
285 static HRESULT WINAPI InPlaceSite_OnUIActivate(IOleInPlaceSite *iface)
286 {
287     CHECK_EXPECT(OnUIActivate);
288     return S_OK;
289 }
290
291 static HRESULT WINAPI InPlaceSite_GetWindowContext(IOleInPlaceSite *iface,
292         IOleInPlaceFrame **ppFrame, IOleInPlaceUIWindow **ppDoc, LPRECT lprcPosRect,
293         LPRECT lprcClipRect, LPOLEINPLACEFRAMEINFO lpFrameInfo)
294 {
295     static const RECT rect = {0,0,500,500};
296
297     CHECK_EXPECT(GetWindowContext);
298
299     ok(ppFrame != NULL, "ppFrame = NULL\n");
300     if(ppFrame)
301         *ppFrame = &InPlaceFrame;
302     ok(ppDoc != NULL, "ppDoc = NULL\n");
303     if(ppDoc)
304         *ppDoc = NULL;
305     ok(lprcPosRect != NULL, "lprcPosRect = NULL\n");
306     if(lprcPosRect)
307         memcpy(lprcPosRect, &rect, sizeof(RECT));
308     ok(lprcClipRect != NULL, "lprcClipRect = NULL\n");
309     if(lprcClipRect)
310         memcpy(lprcClipRect, &rect, sizeof(RECT));
311     ok(lpFrameInfo != NULL, "lpFrameInfo = NULL\n");
312     if(lpFrameInfo) {
313         lpFrameInfo->cb = sizeof(*lpFrameInfo);
314         lpFrameInfo->fMDIApp = FALSE;
315         lpFrameInfo->hwndFrame = container_hwnd;
316         lpFrameInfo->haccel = NULL;
317         lpFrameInfo->cAccelEntries = 0;
318     }
319
320     return S_OK;
321 }
322
323 static HRESULT WINAPI InPlaceSite_Scroll(IOleInPlaceSite *iface, SIZE scrollExtant)
324 {
325     ok(0, "unexpected call\n");
326     return E_NOTIMPL;
327 }
328
329 static HRESULT WINAPI InPlaceSite_OnUIDeactivate(IOleInPlaceSite *iface, BOOL fUndoable)
330 {
331     CHECK_EXPECT(OnUIDeactivate);
332     ok(!fUndoable, "fUndoable = TRUE\n");
333     return S_OK;
334 }
335
336 static HRESULT WINAPI InPlaceSite_OnInPlaceDeactivate(IOleInPlaceSite *iface)
337 {
338     CHECK_EXPECT(OnInPlaceDeactivate);
339     return S_OK;
340 }
341
342 static HRESULT WINAPI InPlaceSite_DiscardUndoState(IOleInPlaceSite *iface)
343 {
344     ok(0, "unexpected call\n");
345     return E_NOTIMPL;
346 }
347
348 static HRESULT WINAPI InPlaceSite_DeactivateAndUndo(IOleInPlaceSite *iface)
349 {
350     ok(0, "unexpected call\n");
351     return E_NOTIMPL;
352 }
353
354 static HRESULT WINAPI InPlaceSite_OnPosRectChange(IOleInPlaceSite *iface, LPCRECT lprcPosRect)
355 {
356     ok(0, "unexpected call\n");
357     return E_NOTIMPL;
358 }
359
360 static const IOleInPlaceSiteVtbl InPlaceSiteVtbl = {
361     InPlaceSite_QueryInterface,
362     InPlaceSite_AddRef,
363     InPlaceSite_Release,
364     InPlaceSite_GetWindow,
365     InPlaceSite_ContextSensitiveHelp,
366     InPlaceSite_CanInPlaceActivate,
367     InPlaceSite_OnInPlaceActivate,
368     InPlaceSite_OnUIActivate,
369     InPlaceSite_GetWindowContext,
370     InPlaceSite_Scroll,
371     InPlaceSite_OnUIDeactivate,
372     InPlaceSite_OnInPlaceDeactivate,
373     InPlaceSite_DiscardUndoState,
374     InPlaceSite_DeactivateAndUndo,
375     InPlaceSite_OnPosRectChange
376 };
377
378 static IOleInPlaceSite InPlaceSite = { &InPlaceSiteVtbl };
379
380 static HRESULT WINAPI ClientSite_QueryInterface(IOleClientSite *iface, REFIID riid, void **ppv)
381 {
382     return QueryInterface(riid, ppv);
383 }
384
385 static ULONG WINAPI ClientSite_AddRef(IOleClientSite *iface)
386 {
387     return 2;
388 }
389
390 static ULONG WINAPI ClientSite_Release(IOleClientSite *iface)
391 {
392     return 1;
393 }
394
395 static HRESULT WINAPI ClientSite_SaveObject(IOleClientSite *iface)
396 {
397     ok(0, "unexpected call\n");
398     return E_NOTIMPL;
399 }
400
401 static HRESULT WINAPI ClientSite_GetMoniker(IOleClientSite *iface, DWORD dwAsign, DWORD dwWhichMoniker,
402         IMoniker **ppmon)
403 {
404     ok(0, "unexpected call\n");
405     return E_NOTIMPL;
406 }
407
408 static HRESULT WINAPI ClientSite_GetContainer(IOleClientSite *iface, IOleContainer **ppContainer)
409 {
410     CHECK_EXPECT(GetContainer);
411     ok(ppContainer != NULL, "ppContainer = NULL\n");
412     *ppContainer = &OleContainer;
413     return S_OK;
414 }
415
416 static HRESULT WINAPI ClientSite_ShowObject(IOleClientSite *iface)
417 {
418     ok(0, "unexpected call\n");
419     return E_NOTIMPL;
420 }
421
422 static HRESULT WINAPI ClientSite_OnShowWindow(IOleClientSite *iface, BOOL fShow)
423 {
424     ok(0, "unexpected call\n");
425     return E_NOTIMPL;
426 }
427
428 static HRESULT WINAPI ClientSite_RequestNewObjectLayout(IOleClientSite *iface)
429 {
430     ok(0, "unexpected call\n");
431     return E_NOTIMPL;
432 }
433
434 static const IOleClientSiteVtbl ClientSiteVtbl = {
435     ClientSite_QueryInterface,
436     ClientSite_AddRef,
437     ClientSite_Release,
438     ClientSite_SaveObject,
439     ClientSite_GetMoniker,
440     ClientSite_GetContainer,
441     ClientSite_ShowObject,
442     ClientSite_OnShowWindow,
443     ClientSite_RequestNewObjectLayout
444 };
445
446 static IOleClientSite ClientSite = { &ClientSiteVtbl };
447
448 static HRESULT WINAPI DocumentSite_QueryInterface(IOleDocumentSite *iface, REFIID riid, void **ppv)
449 {
450     return QueryInterface(riid, ppv);
451 }
452
453 static ULONG WINAPI DocumentSite_AddRef(IOleDocumentSite *iface)
454 {
455     return 2;
456 }
457
458 static ULONG WINAPI DocumentSite_Release(IOleDocumentSite *iface)
459 {
460     return 1;
461 }
462
463 static HRESULT WINAPI DocumentSite_ActivateMe(IOleDocumentSite *iface, IOleDocumentView *pViewToActivate)
464 {
465     IOleDocument *document;
466     HRESULT hres;
467
468     CHECK_EXPECT(ActivateMe);
469     ok(pViewToActivate != NULL, "pViewToActivate = NULL\n");
470
471     hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleDocument, (void**)&document);
472     ok(hres == S_OK, "could not get IOleDocument: %08lx\n", hres);
473
474     if(SUCCEEDED(hres)) {
475         hres = IOleDocument_CreateView(document, &InPlaceSite, NULL, 0, &view);
476         ok(hres == S_OK, "CreateView failed: %08lx\n", hres);
477
478         if(SUCCEEDED(hres)) {
479             IOleInPlaceActiveObject *activeobj = NULL;
480             IOleInPlaceSite *inplacesite = NULL;
481             HWND tmp_hwnd = NULL;
482             static RECT rect = {0,0,400,500};
483
484             hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
485             ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
486             ok(inplacesite == &InPlaceSite, "inplacesite=%p, expected %p\n",
487                     inplacesite, &InPlaceSite);
488
489             hres = IOleDocumentView_SetInPlaceSite(view, &InPlaceSite);
490             ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
491
492             hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
493             ok(hres == S_OK, "GetInPlaceSite failed: %08lx\n", hres);
494             ok(inplacesite == &InPlaceSite, "inplacesite=%p, expected %p\n",
495                     inplacesite, &InPlaceSite);
496
497             hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobj);
498             ok(hres == S_OK, "Could not get IOleInPlaceActiveObject: %08lx\n", hres);
499
500             if(activeobj) {
501                 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
502                 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
503                 ok(hwnd == NULL, "hwnd=%p, expeted NULL\n", hwnd);
504             }
505             
506             SET_EXPECT(CanInPlaceActivate);
507             SET_EXPECT(GetWindowContext);
508             SET_EXPECT(GetWindow);
509             SET_EXPECT(OnInPlaceActivate);
510             SET_EXPECT(OnUIActivate);
511             SET_EXPECT(SetActiveObject);
512             SET_EXPECT(ShowUI);
513             expect_SetActiveObject_active = TRUE;
514             hres = IOleDocumentView_UIActivate(view, TRUE);
515             ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
516             CHECK_CALLED(CanInPlaceActivate);
517             CHECK_CALLED(GetWindowContext);
518             CHECK_CALLED(GetWindow);
519             CHECK_CALLED(OnInPlaceActivate);
520             CHECK_CALLED(OnUIActivate);
521             CHECK_CALLED(SetActiveObject);
522             CHECK_CALLED(ShowUI);
523
524             if(activeobj) {
525                 IOleInPlaceActiveObject_GetWindow(activeobj, &hwnd);
526                 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
527                 ok(hwnd != NULL, "hwnd == NULL\n");
528                 if(last_hwnd)
529                     ok(hwnd == last_hwnd, "hwnd != last_hwnd\n");
530             }
531
532             hres = IOleDocumentView_UIActivate(view, TRUE);
533             ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
534
535             if(activeobj) {
536                 IOleInPlaceActiveObject_GetWindow(activeobj, &tmp_hwnd);
537                 ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
538                 ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
539             }
540
541             hres = IOleDocumentView_SetRect(view, &rect);
542             ok(hres == S_OK, "SetRect failed: %08lx\n", hres);
543
544             hres = IOleDocumentView_Show(view, TRUE);
545             ok(hres == S_OK, "Show failed: %08lx\n", hres);
546             
547             if(activeobj)
548                 IOleInPlaceActiveObject_Release(activeobj);
549         }
550
551         IOleDocument_Release(document);
552     }
553
554     return S_OK;
555 }
556
557 static const IOleDocumentSiteVtbl DocumentSiteVtbl = {
558     DocumentSite_QueryInterface,
559     DocumentSite_AddRef,
560     DocumentSite_Release,
561     DocumentSite_ActivateMe
562 };
563
564 static IOleDocumentSite DocumentSite = { &DocumentSiteVtbl };
565
566 static HRESULT WINAPI DocHostUIHandler_QueryInterface(IDocHostUIHandler2 *iface, REFIID riid, void **ppv)
567 {
568     return QueryInterface(riid, ppv);
569 }
570
571 static ULONG WINAPI DocHostUIHandler_AddRef(IDocHostUIHandler2 *iface)
572 {
573     return 2;
574 }
575
576 static ULONG WINAPI DocHostUIHandler_Release(IDocHostUIHandler2 *iface)
577 {
578     return 1;
579 }
580
581 static HRESULT WINAPI DocHostUIHandler_ShowContextMenu(IDocHostUIHandler2 *iface, DWORD dwID, POINT *ppt,
582         IUnknown *pcmdtReserved, IDispatch *pdicpReserved)
583 {
584     ok(0, "unexpected call\n");
585     return E_NOTIMPL;
586 }
587
588 static HRESULT WINAPI DocHostUIHandler_GetHostInfo(IDocHostUIHandler2 *iface, DOCHOSTUIINFO *pInfo)
589 {
590     CHECK_EXPECT(GetHostInfo);
591     ok(pInfo != NULL, "pInfo=NULL\n");
592     if(pInfo) {
593         ok(pInfo->cbSize == sizeof(DOCHOSTUIINFO), "pInfo->cbSize=%lu, expected %u\n",
594                 pInfo->cbSize, sizeof(DOCHOSTUIINFO));
595         ok(!pInfo->dwFlags, "pInfo->dwFlags=%08lx, expected 0\n", pInfo->dwFlags);
596         pInfo->dwFlags = DOCHOSTUIFLAG_DISABLE_HELP_MENU | DOCHOSTUIFLAG_DISABLE_SCRIPT_INACTIVE
597             | DOCHOSTUIFLAG_ACTIVATE_CLIENTHIT_ONLY | DOCHOSTUIFLAG_ENABLE_INPLACE_NAVIGATION
598             | DOCHOSTUIFLAG_IME_ENABLE_RECONVERSION;
599         ok(!pInfo->dwDoubleClick, "pInfo->dwDoubleClick=%08lx, expected 0\n", pInfo->dwDoubleClick);
600         ok(!pInfo->pchHostCss, "pInfo->pchHostCss=%p, expected NULL\n", pInfo->pchHostCss);
601         ok(!pInfo->pchHostNS, "pInfo->pchhostNS=%p, expected NULL\n", pInfo->pchHostNS);
602     }
603     return S_OK;
604 }
605
606 static HRESULT WINAPI DocHostUIHandler_ShowUI(IDocHostUIHandler2 *iface, DWORD dwID,
607         IOleInPlaceActiveObject *pActiveObject, IOleCommandTarget *pCommandTarget,
608         IOleInPlaceFrame *pFrame, IOleInPlaceUIWindow *pDoc)
609 {
610     CHECK_EXPECT(ShowUI);
611
612     ok(dwID == 0, "dwID=%ld, expected 0\n", dwID);
613     ok(pActiveObject != NULL, "pActiveObject = NULL\n");
614     ok(pCommandTarget != NULL, "pCommandTarget = NULL\n");
615     ok(pFrame == &InPlaceFrame, "pFrame=%p, expected %p\n", pFrame, &InPlaceFrame);
616     ok(pDoc == NULL, "pDoc=%p, expected NULL\n", pDoc);
617
618     return S_OK;
619 }
620
621 static HRESULT WINAPI DocHostUIHandler_HideUI(IDocHostUIHandler2 *iface)
622 {
623     CHECK_EXPECT(HideUI);
624     return S_OK;
625 }
626
627 static HRESULT WINAPI DocHostUIHandler_UpdateUI(IDocHostUIHandler2 *iface)
628 {
629     ok(0, "unexpected call\n");
630     return E_NOTIMPL;
631 }
632
633 static HRESULT WINAPI DocHostUIHandler_EnableModeless(IDocHostUIHandler2 *iface, BOOL fEnable)
634 {
635     ok(0, "unexpected call\n");
636     return E_NOTIMPL;
637 }
638
639 static HRESULT WINAPI DocHostUIHandler_OnDocWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
640 {
641     ok(0, "unexpected call\n");
642     return E_NOTIMPL;
643 }
644
645 static HRESULT WINAPI DocHostUIHandler_OnFrameWindowActivate(IDocHostUIHandler2 *iface, BOOL fActivate)
646 {
647     ok(0, "unexpected call\n");
648     return E_NOTIMPL;
649 }
650
651 static HRESULT WINAPI DocHostUIHandler_ResizeBorder(IDocHostUIHandler2 *iface, LPCRECT prcBorder,
652         IOleInPlaceUIWindow *pUIWindow, BOOL fRameWindow)
653 {
654     ok(0, "unexpected call\n");
655     return E_NOTIMPL;
656 }
657
658 static HRESULT WINAPI DocHostUIHandler_TranslateAccelerator(IDocHostUIHandler2 *iface, LPMSG lpMsg,
659         const GUID *pguidCmdGroup, DWORD nCmdID)
660 {
661     ok(0, "unexpected call\n");
662     return E_NOTIMPL;
663 }
664
665 static HRESULT WINAPI DocHostUIHandler_GetOptionKeyPath(IDocHostUIHandler2 *iface,
666         LPOLESTR *pchKey, DWORD dw)
667 {
668     CHECK_EXPECT(GetOptionKeyPath);
669     ok(pchKey != NULL, "pchKey = NULL\n");
670     ok(!dw, "dw=%ld, expected 0\n", dw);
671     if(pchKey)
672         ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
673     return S_OK;
674 }
675
676 static HRESULT WINAPI DocHostUIHandler_GetDropTarget(IDocHostUIHandler2 *iface,
677         IDropTarget *pDropTarget, IDropTarget **ppDropTarget)
678 {
679     ok(0, "unexpected call\n");
680     return E_NOTIMPL;
681 }
682
683 static HRESULT WINAPI DocHostUIHandler_GetExternal(IDocHostUIHandler2 *iface, IDispatch **ppDispatch)
684 {
685     ok(0, "unexpected call\n");
686     return E_NOTIMPL;
687 }
688
689 static HRESULT WINAPI DocHostUIHandler_TranslateUrl(IDocHostUIHandler2 *iface, DWORD dwTranslate,
690         OLECHAR *pchURLIn, OLECHAR **ppchURLOut)
691 {
692     ok(0, "unexpected call\n");
693     return E_NOTIMPL;
694 }
695
696 static HRESULT WINAPI DocHostUIHandler_FilterDataObject(IDocHostUIHandler2 *iface, IDataObject *pDO,
697         IDataObject **ppPORet)
698 {
699     ok(0, "unexpected call\n");
700     return E_NOTIMPL;
701 }
702
703 static HRESULT WINAPI DocHostUIHandler_GetOverrideKeyPath(IDocHostUIHandler2 *iface,
704         LPOLESTR *pchKey, DWORD dw)
705 {
706     CHECK_EXPECT(GetOverrideKeyPath);
707     ok(pchKey != NULL, "pchKey = NULL\n");
708     if(pchKey)
709         ok(!*pchKey, "*pchKey=%p, expected NULL\n", *pchKey);
710     ok(!dw, "dw=%ld, xepected 0\n", dw);
711     return S_OK;
712 }
713
714 static const IDocHostUIHandler2Vtbl DocHostUIHandlerVtbl = {
715     DocHostUIHandler_QueryInterface,
716     DocHostUIHandler_AddRef,
717     DocHostUIHandler_Release,
718     DocHostUIHandler_ShowContextMenu,
719     DocHostUIHandler_GetHostInfo,
720     DocHostUIHandler_ShowUI,
721     DocHostUIHandler_HideUI,
722     DocHostUIHandler_UpdateUI,
723     DocHostUIHandler_EnableModeless,
724     DocHostUIHandler_OnDocWindowActivate,
725     DocHostUIHandler_OnFrameWindowActivate,
726     DocHostUIHandler_ResizeBorder,
727     DocHostUIHandler_TranslateAccelerator,
728     DocHostUIHandler_GetOptionKeyPath,
729     DocHostUIHandler_GetDropTarget,
730     DocHostUIHandler_GetExternal,
731     DocHostUIHandler_TranslateUrl,
732     DocHostUIHandler_FilterDataObject,
733     DocHostUIHandler_GetOverrideKeyPath
734 };
735
736 static IDocHostUIHandler2 DocHostUIHandler = { &DocHostUIHandlerVtbl };
737
738 static HRESULT QueryInterface(REFIID riid, void **ppv)
739 {
740     *ppv = NULL;
741
742     if(IsEqualGUID(&IID_IUnknown, riid) || IsEqualGUID(&IID_IOleClientSite, riid))
743         *ppv = &ClientSite;
744     else if(IsEqualGUID(&IID_IOleDocumentSite, riid))
745         *ppv = &DocumentSite;
746     else if(IsEqualGUID(&IID_IDocHostUIHandler, riid) || IsEqualGUID(&IID_IDocHostUIHandler2, riid)) {
747         *ppv = &DocHostUIHandler;
748     }
749     else if(IsEqualGUID(&IID_IOleContainer, riid))
750         *ppv = &OleContainer;
751     else if(IsEqualGUID(&IID_IOleWindow, riid) || IsEqualGUID(&IID_IOleInPlaceSite, riid))
752         *ppv = &InPlaceSite;
753     else if(IsEqualGUID(&IID_IOleInPlaceUIWindow, riid) || IsEqualGUID(&IID_IOleInPlaceFrame, riid))
754         *ppv = &InPlaceFrame;
755
756     /* TODO:
757      * IDispatch
758      * IServiceProvider
759      * IOleCommandTarget
760      * {D48A6EC6-6A4A-11CF-94A7-444553540000}
761      * {7BB0B520-B1A7-11D2-BB23-00C04F79ABCD}
762      * {000670BA-0000-0000-C000-000000000046}
763      */
764
765     if(*ppv)
766         return S_OK;
767     return E_NOINTERFACE;
768 }
769
770 static LRESULT WINAPI wnd_proc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
771 {
772     return DefWindowProc(hwnd, msg, wParam, lParam);
773 }
774
775 static void test_Persist()
776 {
777     IPersistMoniker *persist_mon;
778     IPersistFile *persist_file;
779     GUID guid;
780     HRESULT hres;
781
782     hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IPersistFile, (void**)&persist_file);
783     ok(hres == S_OK, "QueryInterface(IID_IPersist) failed: %08lx\n", hres);
784     if(SUCCEEDED(hres)) {
785         hres = IPersist_GetClassID(persist_file, NULL);
786         ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
787
788         hres = IPersist_GetClassID(persist_file, &guid);
789         ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
790         ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
791
792         IPersist_Release(persist_file);
793     }
794
795     hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IPersistMoniker, (void**)&persist_mon);
796     ok(hres == S_OK, "QueryInterface(IID_IPersistMoniker) failed: %08lx\n", hres);
797     if(SUCCEEDED(hres)) {
798         hres = IPersistMoniker_GetClassID(persist_mon, NULL);
799         ok(hres == E_INVALIDARG, "GetClassID returned: %08lx, expected E_INVALIDARG\n", hres);
800
801         hres = IPersistMoniker_GetClassID(persist_mon, &guid);
802         ok(hres == S_OK, "GetClassID failed: %08lx\n", hres);
803         ok(IsEqualGUID(&CLSID_HTMLDocument, &guid), "guid != CLSID_HTMLDocument\n");
804
805         IPersistMoniker_Release(persist_mon);
806     }
807 }
808
809 static void test_HTMLDocument(void)
810 {
811     IOleObject *oleobj = NULL;
812     IOleClientSite *clientsite = (LPVOID)0xdeadbeef;
813     IOleInPlaceObjectWindowless *windowlessobj = NULL;
814     IOleInPlaceActiveObject *activeobject = NULL;
815     GUID guid;
816     RECT rect = {0,0,500,500};
817     HRESULT hres;
818     ULONG ref;
819
820     static const WCHAR wszHTMLDocumentTest[] =
821         {'H','T','M','L','D','o','c','u','m','e','n','t','T','e','s','t',0};
822     static const WNDCLASSEXW wndclass = {
823         sizeof(WNDCLASSEXW),
824         0,
825         wnd_proc,
826         0, 0, NULL, NULL, NULL, NULL, NULL,
827         wszHTMLDocumentTest,
828         NULL
829     };
830
831     hres = CoCreateInstance(&CLSID_HTMLDocument, NULL, CLSCTX_INPROC_SERVER|CLSCTX_INPROC_HANDLER,
832             &IID_IUnknown, (void**)&htmldoc_unk);
833     ok(hres == S_OK, "CoCreateInstance failed: %08lx\n", hres);
834     if(FAILED(hres))
835         return;
836
837     RegisterClassExW(&wndclass);
838     container_hwnd = CreateWindowW(wszHTMLDocumentTest, wszHTMLDocumentTest,
839             WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
840             CW_USEDEFAULT, NULL, NULL, NULL, NULL);
841
842     test_Persist();
843
844     hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleInPlaceObjectWindowless,
845             (void**)&windowlessobj);
846     ok(hres == S_OK, "Could not get IOleInPlaceObjectWindowless interface: %08lx\n", hres);
847              
848     hres = IUnknown_QueryInterface(htmldoc_unk, &IID_IOleObject, (void**)&oleobj);
849     ok(hres == S_OK, "QueryInterface(IID_IOleObject) failed: %08lx\n", hres);
850     if(oleobj) {
851         hres = IOleObject_GetUserClassID(oleobj, NULL);
852         ok(hres == E_INVALIDARG, "GetUserClassID returned: %08lx, expected E_INVALIDARG\n", hres);
853
854         hres = IOleObject_GetUserClassID(oleobj, &guid);
855         ok(hres == S_OK, "GetUserClassID failed: %08lx\n", hres);
856         ok(IsEqualGUID(&guid, &CLSID_HTMLDocument), "guid != CLSID_HTMLDocument\n");
857
858         hres = IOleObject_GetClientSite(oleobj, &clientsite);
859         ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
860         ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
861
862         SET_EXPECT(GetHostInfo);
863         SET_EXPECT(GetOptionKeyPath);
864         SET_EXPECT(GetOverrideKeyPath);
865         SET_EXPECT(GetWindow);
866         hres = IOleObject_SetClientSite(oleobj, &ClientSite);
867         ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
868         CHECK_CALLED(GetHostInfo);
869         CHECK_CALLED(GetOptionKeyPath);
870         CHECK_CALLED(GetOverrideKeyPath);
871         CHECK_CALLED(GetWindow);
872
873         hres = IOleObject_GetClientSite(oleobj, &clientsite);
874         ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
875         ok(clientsite == &ClientSite, "GetClientSite() = %p, expected %p\n", clientsite, &ClientSite);
876
877         if(windowlessobj) {
878             hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
879             ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
880         }
881
882         SET_EXPECT(GetContainer);
883         SET_EXPECT(LockContainer);
884         SET_EXPECT(ActivateMe);
885         expect_LockContainer_fLock = TRUE;
886         hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
887         ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
888         CHECK_CALLED(GetContainer);
889         CHECK_CALLED(LockContainer);
890         CHECK_CALLED(ActivateMe);
891     }
892
893     hres = IOleDocumentView_QueryInterface(view, &IID_IOleInPlaceActiveObject, (void**)&activeobject);
894     ok(hres == S_OK, "Could not get IOleInPlaceActiveObject interface: %08lx\n", hres);
895
896     if(activeobject) {
897         HWND tmp_hwnd;
898         hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
899         ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
900         ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
901     }
902
903     if(view) {
904         SET_EXPECT(SetActiveObject);
905         SET_EXPECT(HideUI);
906         SET_EXPECT(OnUIDeactivate);
907         expect_SetActiveObject_active = FALSE;
908         hres = IOleDocumentView_UIActivate(view, FALSE);
909         ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
910         CHECK_CALLED(SetActiveObject);
911         CHECK_CALLED(HideUI);
912         CHECK_CALLED(OnUIDeactivate);
913     }
914
915     if(activeobject) {
916         HWND tmp_hwnd;
917         hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
918         ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
919         ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
920     }
921     
922     if(windowlessobj) {
923         SET_EXPECT(OnInPlaceDeactivate);
924         hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
925         ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
926         CHECK_CALLED(OnInPlaceDeactivate);
927     }
928
929     if(activeobject) {
930         HWND tmp_hwnd;
931         hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
932         ok(hres == E_FAIL, "GetWindow returned %08lx, expected E_FAIL\n", hres);
933         ok(IsWindow(hwnd), "hwnd is destroyed\n");
934     }
935     
936     if(view) {
937         hres = IOleDocumentView_Show(view, FALSE);
938         ok(hres == S_OK, "Show failed: %08lx\n", hres);
939     }
940
941     if(windowlessobj) {
942         hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
943         ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
944     }
945
946     if(view) {
947         IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
948
949         hres = IOleDocumentView_Show(view, FALSE);
950         ok(hres == S_OK, "Show failed: %08lx\n", hres);
951
952         hres = IOleDocumentView_CloseView(view, 0);
953         ok(hres == S_OK, "CloseVire failed: %08lx\n", hres);
954
955         hres = IOleDocumentView_SetInPlaceSite(view, NULL);
956         ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
957
958         hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
959         ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
960         ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
961     }
962
963     if(oleobj) {
964         SET_EXPECT(GetContainer);
965         SET_EXPECT(LockContainer);
966         expect_LockContainer_fLock = FALSE;
967         hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
968         ok(hres == S_OK, "Close failed: %08lx\n", hres);
969         CHECK_CALLED(GetContainer);
970         CHECK_CALLED(LockContainer);
971
972         if(view)
973             IOleDocumentView_Release(view);
974
975         /* Activate HTMLDocument again */
976         last_hwnd = hwnd;
977
978         hres = IOleObject_GetClientSite(oleobj, &clientsite);
979         ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
980
981         hres = IOleObject_SetClientSite(oleobj, NULL);
982         ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
983
984         hres = IOleObject_GetClientSite(oleobj, &clientsite);
985         ok(hres == S_OK, "GetClientSite failed: %08lx\n", hres);
986         ok(clientsite == NULL, "GetClientSite() = %p, expected NULL\n", clientsite);
987
988         SET_EXPECT(GetHostInfo);
989         SET_EXPECT(GetWindow);
990         hres = IOleObject_SetClientSite(oleobj, &ClientSite);
991         ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
992         CHECK_CALLED(GetHostInfo);
993         CHECK_CALLED(GetWindow);
994
995         if(windowlessobj) {
996             hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
997             ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
998         }
999
1000         SET_EXPECT(GetContainer);
1001         SET_EXPECT(LockContainer);
1002         SET_EXPECT(ActivateMe);
1003         expect_LockContainer_fLock = TRUE;
1004         hres = IOleObject_DoVerb(oleobj, OLEIVERB_SHOW, NULL, &ClientSite, -1, container_hwnd, &rect);
1005         ok(hres == S_OK, "DoVerb failed: %08lx\n", hres);
1006         CHECK_CALLED(GetContainer);
1007         CHECK_CALLED(LockContainer);
1008         CHECK_CALLED(ActivateMe);
1009     }
1010
1011     if(activeobject) {
1012         HWND tmp_hwnd;
1013         hres = IOleInPlaceActiveObject_GetWindow(activeobject, &tmp_hwnd);
1014         ok(hres == S_OK, "GetWindow failed: %08lx\n", hres);
1015         ok(tmp_hwnd == hwnd, "tmp_hwnd=%p, expected %p\n", tmp_hwnd, hwnd);
1016     }
1017
1018     if(view) {
1019         SET_EXPECT(SetActiveObject);
1020         SET_EXPECT(HideUI);
1021         SET_EXPECT(OnUIDeactivate);
1022         expect_SetActiveObject_active = FALSE;
1023         hres = IOleDocumentView_UIActivate(view, FALSE);
1024         ok(hres == S_OK, "UIActivate failed: %08lx\n", hres);
1025         CHECK_CALLED(SetActiveObject);
1026         CHECK_CALLED(HideUI);
1027         CHECK_CALLED(OnUIDeactivate);
1028     }
1029
1030     if(windowlessobj) {
1031         SET_EXPECT(OnInPlaceDeactivate);
1032         hres = IOleInPlaceObjectWindowless_InPlaceDeactivate(windowlessobj);
1033         ok(hres == S_OK, "InPlaceDeactivate failed: %08lx\n", hres);
1034         CHECK_CALLED(OnInPlaceDeactivate);
1035     }
1036
1037     if(view) {
1038         IOleInPlaceSite *inplacesite = (IOleInPlaceSite*)0xff00ff00;
1039
1040         hres = IOleDocumentView_Show(view, FALSE);
1041         ok(hres == S_OK, "Show failed: %08lx\n", hres);
1042
1043         hres = IOleDocumentView_CloseView(view, 0);
1044         ok(hres == S_OK, "CloseVire failed: %08lx\n", hres);
1045
1046         hres = IOleDocumentView_SetInPlaceSite(view, NULL);
1047         ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
1048
1049         hres = IOleDocumentView_GetInPlaceSite(view, &inplacesite);
1050         ok(hres == S_OK, "SetInPlaceSite failed: %08lx\n", hres);
1051         ok(inplacesite == NULL, "inplacesite=%p, expected NULL\n", inplacesite);
1052     }
1053
1054     if(oleobj) {
1055         SET_EXPECT(GetContainer);
1056         SET_EXPECT(LockContainer);
1057         expect_LockContainer_fLock = FALSE;
1058         hres = IOleObject_Close(oleobj, OLECLOSE_NOSAVE);
1059         ok(hres == S_OK, "Close failed: %08lx\n", hres);
1060         CHECK_CALLED(GetContainer);
1061         CHECK_CALLED(LockContainer);
1062
1063         hres = IOleObject_GetClientSite(oleobj, &clientsite);
1064         ok(clientsite == &ClientSite, "clientsite=%p, expected %p\n", clientsite, &ClientSite);
1065
1066         hres = IOleObject_SetClientSite(oleobj, NULL);
1067         ok(hres == S_OK, "SetClientSite failed: %08lx\n", hres);
1068     }
1069
1070     if(windowlessobj)
1071         IOleInPlaceObjectWindowless_Release(windowlessobj);
1072     if(oleobj)
1073         IOleObject_Release(oleobj);
1074     if(view)
1075         IOleDocumentView_Release(view);
1076     if(activeobject)
1077         IOleInPlaceActiveObject_Release(activeobject);
1078
1079     ok(IsWindow(hwnd), "hwnd is destroyed\n");
1080
1081     ref = IUnknown_Release(htmldoc_unk);
1082     ok(ref == 0, "ref=%ld, expected 0\n", ref);
1083
1084     ok(!IsWindow(hwnd), "hwnd is not destroyed\n");
1085
1086     DestroyWindow(container_hwnd);
1087 }
1088
1089 START_TEST(htmldoc)
1090 {
1091     CoInitialize(NULL);
1092
1093     test_HTMLDocument();
1094
1095     CoUninitialize();
1096 }