strmbase: Avoid leaking references to the sink's peer in IVideoWindow::SetWindowForeg...
[wine.git] / dlls / mshtml / main.c
blob29396a5475abb7594d17ba38b63ef0272ce4b440
1 /*
2 * MSHTML Class Factory
4 * Copyright 2002 Lionel Ulmer
5 * Copyright 2003 Mike McCormack
6 * Copyright 2005 Jacek Caban
8 * This library is free software; you can redistribute it and/or
9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation; either
11 * version 2.1 of the License, or (at your option) any later version.
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
16 * Lesser General Public License for more details.
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
23 #include <stdarg.h>
24 #include <stdio.h>
26 #define COBJMACROS
28 #include "windef.h"
29 #include "winbase.h"
30 #include "winuser.h"
31 #include "winreg.h"
32 #include "ole2.h"
33 #include "advpub.h"
34 #include "shlwapi.h"
35 #include "optary.h"
36 #include "rpcproxy.h"
37 #include "shlguid.h"
38 #include "mlang.h"
39 #include "wininet.h"
41 #include "wine/debug.h"
43 #define INIT_GUID
44 #include "mshtml_private.h"
45 #include "resource.h"
46 #include "pluginhost.h"
47 #include "mscoree.h"
49 WINE_DEFAULT_DEBUG_CHANNEL(mshtml);
51 HINSTANCE hInst;
52 DWORD mshtml_tls = TLS_OUT_OF_INDEXES;
54 static HINSTANCE shdoclc = NULL;
55 static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
56 static IMultiLanguage2 *mlang;
57 static IInternetSecurityManager *security_manager;
58 static unsigned global_max_compat_mode = COMPAT_MODE_IE11;
59 static struct list compat_config = LIST_INIT(compat_config);
61 typedef struct {
62 struct list entry;
63 compat_mode_t max_compat_mode;
64 WCHAR host[1];
65 } compat_config_t;
67 static BOOL ensure_mlang(void)
69 IMultiLanguage2 *new_mlang;
70 HRESULT hres;
72 if(mlang)
73 return TRUE;
75 hres = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
76 &IID_IMultiLanguage2, (void**)&new_mlang);
77 if(FAILED(hres)) {
78 ERR("Could not create CMultiLanguage instance\n");
79 return FALSE;
82 if(InterlockedCompareExchangePointer((void**)&mlang, new_mlang, NULL))
83 IMultiLanguage2_Release(new_mlang);
85 return TRUE;
88 UINT cp_from_charset_string(BSTR charset)
90 MIMECSETINFO info;
91 HRESULT hres;
93 if(!ensure_mlang())
94 return CP_UTF8;
96 hres = IMultiLanguage2_GetCharsetInfo(mlang, charset, &info);
97 if(FAILED(hres)) {
98 FIXME("GetCharsetInfo failed: %08x\n", hres);
99 return CP_UTF8;
102 return info.uiInternetEncoding;
105 BSTR charset_string_from_cp(UINT cp)
107 MIMECPINFO info;
108 HRESULT hres;
110 if(!ensure_mlang())
111 return SysAllocString(NULL);
113 hres = IMultiLanguage2_GetCodePageInfo(mlang, cp, GetUserDefaultUILanguage(), &info);
114 if(FAILED(hres)) {
115 ERR("GetCodePageInfo failed: %08x\n", hres);
116 return SysAllocString(NULL);
119 return SysAllocString(info.wszWebCharset);
122 IInternetSecurityManager *get_security_manager(void)
124 if(!security_manager) {
125 IInternetSecurityManager *manager;
126 HRESULT hres;
128 hres = CoInternetCreateSecurityManager(NULL, &manager, 0);
129 if(FAILED(hres))
130 return NULL;
132 if(InterlockedCompareExchangePointer((void**)&security_manager, manager, NULL))
133 IInternetSecurityManager_Release(manager);
136 return security_manager;
139 static BOOL read_compat_mode(HKEY key, compat_mode_t *r)
141 WCHAR version[32];
142 DWORD type, size;
143 LSTATUS status;
145 static const WCHAR max_compat_modeW[] = {'M','a','x','C','o','m','p','a','t','M','o','d','e',0};
147 size = sizeof(version);
148 status = RegQueryValueExW(key, max_compat_modeW, NULL, &type, (BYTE*)version, &size);
149 if(status != ERROR_SUCCESS || type != REG_SZ)
150 return FALSE;
152 return parse_compat_version(version, r);
155 static BOOL WINAPI load_compat_settings(INIT_ONCE *once, void *param, void **context)
157 WCHAR key_name[INTERNET_MAX_HOST_NAME_LENGTH];
158 DWORD index = 0, name_size;
159 compat_config_t *new_entry;
160 compat_mode_t max_compat_mode;
161 HKEY key, host_key;
162 DWORD res;
164 static const WCHAR key_nameW[] = {
165 'S','o','f','t','w','a','r','e',
166 '\\','W','i','n','e',
167 '\\','M','S','H','T','M','L',
168 '\\','C','o','m','p','a','t','M','o','d','e',0};
170 /* @@ Wine registry key: HKCU\Software\Wine\MSHTML\CompatMode */
171 res = RegOpenKeyW(HKEY_CURRENT_USER, key_nameW, &key);
172 if(res != ERROR_SUCCESS)
173 return TRUE;
175 if(read_compat_mode(key, &max_compat_mode)) {
176 TRACE("Setting global max compat mode to %u\n", max_compat_mode);
177 global_max_compat_mode = max_compat_mode;
180 while(1) {
181 res = RegEnumKeyW(key, index, key_name, ARRAY_SIZE(key_name));
182 if(res == ERROR_NO_MORE_ITEMS)
183 break;
184 index++;
185 if(res != ERROR_SUCCESS) {
186 WARN("RegEnumKey failed: %u\n", GetLastError());
187 continue;
190 name_size = lstrlenW(key_name) + 1;
191 new_entry = heap_alloc(FIELD_OFFSET(compat_config_t, host[name_size]));
192 if(!new_entry)
193 continue;
195 new_entry->max_compat_mode = COMPAT_MODE_IE11;
196 memcpy(new_entry->host, key_name, name_size * sizeof(WCHAR));
197 list_add_tail(&compat_config, &new_entry->entry);
199 res = RegOpenKeyW(key, key_name, &host_key);
200 if(res != ERROR_SUCCESS)
201 continue;
203 if(read_compat_mode(host_key, &max_compat_mode)) {
204 TRACE("Setting max compat mode for %s to %u\n", debugstr_w(key_name), max_compat_mode);
205 new_entry->max_compat_mode = max_compat_mode;
208 RegCloseKey(host_key);
211 RegCloseKey(key);
212 return TRUE;
215 compat_mode_t get_max_compat_mode(IUri *uri)
217 compat_config_t *iter;
218 size_t len, iter_len;
219 BSTR host;
220 HRESULT hres;
222 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
223 InitOnceExecuteOnce(&init_once, load_compat_settings, NULL, NULL);
225 if(!uri)
226 return global_max_compat_mode;
227 hres = IUri_GetHost(uri, &host);
228 if(FAILED(hres))
229 return global_max_compat_mode;
230 len = SysStringLen(host);
232 LIST_FOR_EACH_ENTRY(iter, &compat_config, compat_config_t, entry) {
233 iter_len = lstrlenW(iter->host);
234 /* If configured host starts with '.', we also match subdomains */
235 if((len == iter_len || (iter->host[0] == '.' && len > iter_len))
236 && !memcmp(host + len - iter_len, iter->host, iter_len * sizeof(WCHAR))) {
237 TRACE("Found max mode %u\n", iter->max_compat_mode);
238 return iter->max_compat_mode;
242 SysFreeString(host);
243 TRACE("Using global max mode %u\n", global_max_compat_mode);
244 return global_max_compat_mode;
247 static void thread_detach(void)
249 thread_data_t *thread_data;
251 thread_data = get_thread_data(FALSE);
252 if(!thread_data)
253 return;
255 if(thread_data->thread_hwnd)
256 DestroyWindow(thread_data->thread_hwnd);
258 heap_free(thread_data);
261 static void free_strings(void)
263 unsigned int i;
264 for(i = 0; i < ARRAY_SIZE(status_strings); i++)
265 heap_free(status_strings[i]);
268 static void process_detach(void)
270 compat_config_t *config;
272 close_gecko();
273 release_typelib();
275 while(!list_empty(&compat_config)) {
276 config = LIST_ENTRY(list_head(&compat_config), compat_config_t, entry);
277 list_remove(&config->entry);
278 heap_free(config);
281 if(shdoclc)
282 FreeLibrary(shdoclc);
283 if(mshtml_tls != TLS_OUT_OF_INDEXES)
284 TlsFree(mshtml_tls);
285 if(mlang)
286 IMultiLanguage2_Release(mlang);
287 if(security_manager)
288 IInternetSecurityManager_Release(security_manager);
290 free_strings();
293 void set_statustext(HTMLDocumentObj* doc, INT id, LPCWSTR arg)
295 int index = id - IDS_STATUS_FIRST;
296 WCHAR *p = status_strings[index];
297 DWORD len;
299 if(!doc->frame)
300 return;
302 if(!p) {
303 len = 255;
304 p = heap_alloc(len * sizeof(WCHAR));
305 len = LoadStringW(hInst, id, p, len) + 1;
306 p = heap_realloc(p, len * sizeof(WCHAR));
307 if(InterlockedCompareExchangePointer((void**)&status_strings[index], p, NULL)) {
308 heap_free(p);
309 p = status_strings[index];
313 if(arg) {
314 WCHAR *buf;
316 len = lstrlenW(p) + lstrlenW(arg) - 1;
317 buf = heap_alloc(len * sizeof(WCHAR));
319 swprintf(buf, len, p, arg);
321 p = buf;
324 IOleInPlaceFrame_SetStatusText(doc->frame, p);
326 if(arg)
327 heap_free(p);
330 HRESULT do_query_service(IUnknown *unk, REFGUID guid_service, REFIID riid, void **ppv)
332 IServiceProvider *sp;
333 HRESULT hres;
335 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&sp);
336 if(FAILED(hres))
337 return hres;
339 hres = IServiceProvider_QueryService(sp, guid_service, riid, ppv);
340 IServiceProvider_Release(sp);
341 return hres;
344 HINSTANCE get_shdoclc(void)
346 static const WCHAR wszShdoclc[] =
347 {'s','h','d','o','c','l','c','.','d','l','l',0};
349 if(shdoclc)
350 return shdoclc;
352 return shdoclc = LoadLibraryExW(wszShdoclc, NULL, LOAD_LIBRARY_AS_DATAFILE);
355 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID reserved)
357 switch(fdwReason) {
358 case DLL_PROCESS_ATTACH:
359 hInst = hInstDLL;
360 break;
361 case DLL_PROCESS_DETACH:
362 if (reserved) break;
363 process_detach();
364 break;
365 case DLL_THREAD_DETACH:
366 thread_detach();
367 break;
369 return TRUE;
372 /***********************************************************
373 * ClassFactory implementation
375 typedef HRESULT (*CreateInstanceFunc)(IUnknown*,REFIID,void**);
376 typedef struct {
377 IClassFactory IClassFactory_iface;
378 LONG ref;
379 CreateInstanceFunc fnCreateInstance;
380 } ClassFactory;
382 static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
384 return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
387 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFGUID riid, void **ppvObject)
389 if(IsEqualGUID(&IID_IClassFactory, riid) || IsEqualGUID(&IID_IUnknown, riid)) {
390 IClassFactory_AddRef(iface);
391 *ppvObject = iface;
392 return S_OK;
395 WARN("not supported iid %s\n", debugstr_mshtml_guid(riid));
396 *ppvObject = NULL;
397 return E_NOINTERFACE;
400 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
402 ClassFactory *This = impl_from_IClassFactory(iface);
403 ULONG ref = InterlockedIncrement(&This->ref);
404 TRACE("(%p) ref = %u\n", This, ref);
405 return ref;
408 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
410 ClassFactory *This = impl_from_IClassFactory(iface);
411 ULONG ref = InterlockedDecrement(&This->ref);
413 TRACE("(%p) ref = %u\n", This, ref);
415 if(!ref) {
416 heap_free(This);
419 return ref;
422 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
423 REFIID riid, void **ppvObject)
425 ClassFactory *This = impl_from_IClassFactory(iface);
426 return This->fnCreateInstance(pUnkOuter, riid, ppvObject);
429 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
431 TRACE("(%p)->(%x)\n", iface, dolock);
433 /* We never unload the DLL. See DllCanUnloadNow(). */
434 return S_OK;
437 static const IClassFactoryVtbl HTMLClassFactoryVtbl = {
438 ClassFactory_QueryInterface,
439 ClassFactory_AddRef,
440 ClassFactory_Release,
441 ClassFactory_CreateInstance,
442 ClassFactory_LockServer
445 static HRESULT ClassFactory_Create(REFIID riid, void **ppv, CreateInstanceFunc fnCreateInstance)
447 ClassFactory *ret = heap_alloc(sizeof(ClassFactory));
448 HRESULT hres;
450 ret->IClassFactory_iface.lpVtbl = &HTMLClassFactoryVtbl;
451 ret->ref = 0;
452 ret->fnCreateInstance = fnCreateInstance;
454 hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
455 if(FAILED(hres)) {
456 heap_free(ret);
457 *ppv = NULL;
459 return hres;
462 /******************************************************************
463 * DllGetClassObject (MSHTML.@)
465 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
467 if(IsEqualGUID(&CLSID_HTMLDocument, rclsid)) {
468 TRACE("(CLSID_HTMLDocument %s %p)\n", debugstr_mshtml_guid(riid), ppv);
469 return ClassFactory_Create(riid, ppv, HTMLDocument_Create);
470 }else if(IsEqualGUID(&CLSID_MHTMLDocument, rclsid)) {
471 TRACE("(CLSID_MHTMLDocument %s %p)\n", debugstr_mshtml_guid(riid), ppv);
472 return ClassFactory_Create(riid, ppv, MHTMLDocument_Create);
473 }else if(IsEqualGUID(&CLSID_AboutProtocol, rclsid)) {
474 TRACE("(CLSID_AboutProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
475 return ProtocolFactory_Create(rclsid, riid, ppv);
476 }else if(IsEqualGUID(&CLSID_JSProtocol, rclsid)) {
477 TRACE("(CLSID_JSProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
478 return ProtocolFactory_Create(rclsid, riid, ppv);
479 }else if(IsEqualGUID(&CLSID_MailtoProtocol, rclsid)) {
480 TRACE("(CLSID_MailtoProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
481 return ProtocolFactory_Create(rclsid, riid, ppv);
482 }else if(IsEqualGUID(&CLSID_ResProtocol, rclsid)) {
483 TRACE("(CLSID_ResProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
484 return ProtocolFactory_Create(rclsid, riid, ppv);
485 }else if(IsEqualGUID(&CLSID_SysimageProtocol, rclsid)) {
486 TRACE("(CLSID_SysimageProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
487 return ProtocolFactory_Create(rclsid, riid, ppv);
488 }else if(IsEqualGUID(&CLSID_HTMLLoadOptions, rclsid)) {
489 TRACE("(CLSID_HTMLLoadOptions %s %p)\n", debugstr_mshtml_guid(riid), ppv);
490 return ClassFactory_Create(riid, ppv, HTMLLoadOptions_Create);
493 FIXME("Unknown class %s\n", debugstr_guid(rclsid));
494 return CLASS_E_CLASSNOTAVAILABLE;
497 /******************************************************************
498 * DllCanUnloadNow (MSHTML.@)
500 HRESULT WINAPI DllCanUnloadNow(void)
502 TRACE("()\n");
503 /* The cost of keeping this DLL in memory is small. */
504 return S_FALSE;
507 /***********************************************************************
508 * RunHTMLApplication (MSHTML.@)
510 * Appears to have the same prototype as WinMain.
512 HRESULT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst,
513 LPSTR szCmdLine, INT nCmdShow )
515 FIXME("%p %p %s %d\n", hinst, hPrevInst, debugstr_a(szCmdLine), nCmdShow );
516 return S_OK;
519 /***********************************************************************
520 * RNIGetCompatibleVersion (MSHTML.@)
522 DWORD WINAPI RNIGetCompatibleVersion(void)
524 TRACE("()\n");
525 return 0x20000;
528 /***********************************************************************
529 * DllInstall (MSHTML.@)
531 HRESULT WINAPI DllInstall(BOOL bInstall, LPCWSTR cmdline)
533 FIXME("stub %d %s: returning S_OK\n", bInstall, debugstr_w(cmdline));
534 return S_OK;
537 /***********************************************************************
538 * ShowHTMLDialog (MSHTML.@)
540 HRESULT WINAPI ShowHTMLDialog(HWND hwndParent, IMoniker *pMk, VARIANT *pvarArgIn,
541 WCHAR *pchOptions, VARIANT *pvarArgOut)
543 FIXME("(%p %p %p %s %p)\n", hwndParent, pMk, pvarArgIn, debugstr_w(pchOptions), pvarArgOut);
544 return E_NOTIMPL;
547 /***********************************************************************
548 * PrintHTML (MSHTML.@)
550 void WINAPI PrintHTML(HWND hwnd, HINSTANCE handle, LPCSTR cmdline, INT show)
552 FIXME("(%p %p %s %x)\n", hwnd, handle, debugstr_a(cmdline), show);
555 DEFINE_GUID(CLSID_CBackgroundPropertyPage, 0x3050F232, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
556 DEFINE_GUID(CLSID_CCDAnchorPropertyPage, 0x3050F1FC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
557 DEFINE_GUID(CLSID_CCDGenericPropertyPage, 0x3050F17F, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
558 DEFINE_GUID(CLSID_CDwnBindInfo, 0x3050F3C2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
559 DEFINE_GUID(CLSID_CHiFiUses, 0x5AAF51B3, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
560 DEFINE_GUID(CLSID_CHtmlComponentConstructor, 0x3050F4F8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
561 DEFINE_GUID(CLSID_CInlineStylePropertyPage, 0x3050F296, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
562 DEFINE_GUID(CLSID_CPeerHandler, 0x5AAF51B2, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
563 DEFINE_GUID(CLSID_CRecalcEngine, 0x3050F499, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
564 DEFINE_GUID(CLSID_CSvrOMUses, 0x3050F4F0, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
565 DEFINE_GUID(CLSID_CrSource, 0x65014010, 0x9F62, 0x11D1, 0xA6,0x51, 0x00,0x60,0x08,0x11,0xD5,0xCE);
566 DEFINE_GUID(CLSID_ExternalFrameworkSite, 0x3050F163, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
567 DEFINE_GUID(CLSID_HTADocument, 0x3050F5C8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
568 DEFINE_GUID(CLSID_HTMLPluginDocument, 0x25336921, 0x03F9, 0x11CF, 0x8F,0xD0, 0x00,0xAA,0x00,0x68,0x6F,0x13);
569 DEFINE_GUID(CLSID_HTMLPopup, 0x3050F667, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
570 DEFINE_GUID(CLSID_HTMLPopupDoc, 0x3050F67D, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
571 DEFINE_GUID(CLSID_HTMLServerDoc, 0x3050F4E7, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
572 DEFINE_GUID(CLSID_IImageDecodeFilter, 0x607FD4E8, 0x0A03, 0x11D1, 0xAB,0x1D, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
573 DEFINE_GUID(CLSID_IImgCtx, 0x3050F3D6, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
574 DEFINE_GUID(CLSID_IntDitherer, 0x05F6FE1A, 0xECEF, 0x11D0, 0xAA,0xE7, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
575 DEFINE_GUID(CLSID_TridentAPI, 0x429AF92C, 0xA51F, 0x11D2, 0x86,0x1E, 0x00,0xC0,0x4F,0xA3,0x5C,0x89);
577 #define INF_SET_ID(id) \
578 do \
580 static CHAR name[] = #id; \
582 pse[i].pszName = name; \
583 clsids[i++] = &id; \
584 } while (0)
586 #define INF_SET_CLSID(clsid) INF_SET_ID(CLSID_ ## clsid)
588 static HRESULT register_server(BOOL do_register)
590 HRESULT hres;
591 HMODULE hAdvpack;
592 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
593 STRTABLEA strtable;
594 STRENTRYA pse[35];
595 static CLSID const *clsids[35];
596 unsigned int i = 0;
598 static const WCHAR wszAdvpack[] = {'a','d','v','p','a','c','k','.','d','l','l',0};
600 TRACE("(%x)\n", do_register);
602 INF_SET_CLSID(AboutProtocol);
603 INF_SET_CLSID(CAnchorBrowsePropertyPage);
604 INF_SET_CLSID(CBackgroundPropertyPage);
605 INF_SET_CLSID(CCDAnchorPropertyPage);
606 INF_SET_CLSID(CCDGenericPropertyPage);
607 INF_SET_CLSID(CDocBrowsePropertyPage);
608 INF_SET_CLSID(CDwnBindInfo);
609 INF_SET_CLSID(CHiFiUses);
610 INF_SET_CLSID(CHtmlComponentConstructor);
611 INF_SET_CLSID(CImageBrowsePropertyPage);
612 INF_SET_CLSID(CInlineStylePropertyPage);
613 INF_SET_CLSID(CPeerHandler);
614 INF_SET_CLSID(CRecalcEngine);
615 INF_SET_CLSID(CSvrOMUses);
616 INF_SET_CLSID(CrSource);
617 INF_SET_CLSID(ExternalFrameworkSite);
618 INF_SET_CLSID(HTADocument);
619 INF_SET_CLSID(HTMLDocument);
620 INF_SET_CLSID(HTMLLoadOptions);
621 INF_SET_CLSID(HTMLPluginDocument);
622 INF_SET_CLSID(HTMLPopup);
623 INF_SET_CLSID(HTMLPopupDoc);
624 INF_SET_CLSID(HTMLServerDoc);
625 INF_SET_CLSID(HTMLWindowProxy);
626 INF_SET_CLSID(IImageDecodeFilter);
627 INF_SET_CLSID(IImgCtx);
628 INF_SET_CLSID(IntDitherer);
629 INF_SET_CLSID(JSProtocol);
630 INF_SET_CLSID(MHTMLDocument);
631 INF_SET_CLSID(MailtoProtocol);
632 INF_SET_CLSID(ResProtocol);
633 INF_SET_CLSID(Scriptlet);
634 INF_SET_CLSID(SysimageProtocol);
635 INF_SET_CLSID(TridentAPI);
636 INF_SET_ID(LIBID_MSHTML);
638 for(i=0; i < ARRAY_SIZE(pse); i++) {
639 pse[i].pszValue = heap_alloc(39);
640 sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
641 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
642 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
643 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
646 strtable.cEntries = ARRAY_SIZE(pse);
647 strtable.pse = pse;
649 hAdvpack = LoadLibraryW(wszAdvpack);
650 pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
652 hres = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll", &strtable);
654 FreeLibrary(hAdvpack);
656 for(i=0; i < ARRAY_SIZE(pse); i++)
657 heap_free(pse[i].pszValue);
659 if(FAILED(hres))
660 ERR("RegInstall failed: %08x\n", hres);
662 return hres;
665 #undef INF_SET_CLSID
666 #undef INF_SET_ID
668 /***********************************************************************
669 * DllRegisterServer (MSHTML.@)
671 HRESULT WINAPI DllRegisterServer(void)
673 HRESULT hres;
675 hres = __wine_register_resources( hInst );
676 if(SUCCEEDED(hres))
677 hres = register_server(TRUE);
678 if(SUCCEEDED(hres))
679 load_gecko();
681 return hres;
684 /***********************************************************************
685 * DllUnregisterServer (MSHTML.@)
687 HRESULT WINAPI DllUnregisterServer(void)
689 HRESULT hres = __wine_unregister_resources( hInst );
690 if(SUCCEEDED(hres)) hres = register_server(FALSE);
691 return hres;
694 const char *debugstr_mshtml_guid(const GUID *iid)
696 #define X(x) if(IsEqualGUID(iid, &x)) return #x
697 X(DIID_HTMLDocumentEvents);
698 X(DIID_HTMLDocumentEvents2);
699 X(DIID_HTMLTableEvents);
700 X(DIID_HTMLTextContainerEvents);
701 X(IID_HTMLPluginContainer);
702 X(IID_IConnectionPoint);
703 X(IID_IConnectionPointContainer);
704 X(IID_ICustomDoc);
705 X(IID_IDispatch);
706 X(IID_IDispatchEx);
707 X(IID_IDispatchJS);
708 X(IID_IDisplayServices);
709 X(IID_UndocumentedScriptIface);
710 X(IID_IEnumConnections);
711 X(IID_IEnumVARIANT);
712 X(IID_IHlinkTarget);
713 X(IID_IHTMLDocument6);
714 X(IID_IHTMLDocument7);
715 X(IID_IHTMLEditServices);
716 X(IID_IHTMLFramesCollection2);
717 X(IID_IHTMLPrivateWindow);
718 X(IID_IHtmlLoadOptions);
719 X(IID_IInternetHostSecurityManager);
720 X(IID_IInternetProtocol);
721 X(IID_IInternetProtocolRoot);
722 X(IID_IManagedObject);
723 X(IID_IMarkupContainer);
724 X(IID_IMarkupServices);
725 X(IID_IMarshal);
726 X(IID_IMonikerProp);
727 X(IID_IObjectIdentity);
728 X(IID_IObjectSafety);
729 X(IID_IObjectWithSite);
730 X(IID_IOleContainer);
731 X(IID_IOleCommandTarget);
732 X(IID_IOleControl);
733 X(IID_IOleDocument);
734 X(IID_IOleDocumentView);
735 X(IID_IOleInPlaceActiveObject);
736 X(IID_IOleInPlaceFrame);
737 X(IID_IOleInPlaceObject);
738 X(IID_IOleInPlaceObjectWindowless);
739 X(IID_IOleInPlaceUIWindow);
740 X(IID_IOleObject);
741 X(IID_IOleWindow);
742 X(IID_IOptionArray);
743 X(IID_IPersist);
744 X(IID_IPersistFile);
745 X(IID_IPersistHistory);
746 X(IID_IPersistMoniker);
747 X(IID_IPersistStreamInit);
748 X(IID_IPropertyNotifySink);
749 X(IID_IProvideClassInfo);
750 X(IID_IProvideClassInfo2);
751 X(IID_IProvideMultipleClassInfo);
752 X(IID_IServiceProvider);
753 X(IID_ISupportErrorInfo);
754 X(IID_ITargetContainer);
755 X(IID_ITravelLogClient);
756 X(IID_IUnknown);
757 X(IID_IViewObject);
758 X(IID_IViewObject2);
759 X(IID_IViewObjectEx);
760 X(IID_nsCycleCollectionISupports);
761 X(IID_nsXPCOMCycleCollectionParticipant);
762 #define XIID(x) X(IID_##x);
763 #define XDIID(x) X(DIID_##x);
764 TID_LIST
765 #undef XIID
766 #undef XDIID
767 #undef X
769 return debugstr_guid(iid);