wined3d: Pass a wined3d_device_context to wined3d_cs_emit_blt_sub_resource().
[wine/zf.git] / dlls / mshtml / main.c
blob7ee260765131d038f6cfb65096449ff0ed77d2c2
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 void (__cdecl *ccp_init)(ExternalCycleCollectionParticipant*,const CCObjCallback*);
55 nsrefcnt (__cdecl *ccref_decr)(nsCycleCollectingAutoRefCnt*,nsISupports*,ExternalCycleCollectionParticipant*);
56 nsrefcnt (__cdecl *ccref_incr)(nsCycleCollectingAutoRefCnt*,nsISupports*);
57 void (__cdecl *ccref_init)(nsCycleCollectingAutoRefCnt*,nsrefcnt);
58 void (__cdecl *describe_cc_node)(nsCycleCollectingAutoRefCnt*,const char*,nsCycleCollectionTraversalCallback*);
59 void (__cdecl *note_cc_edge)(nsISupports*,const char*,nsCycleCollectionTraversalCallback*);
61 static HINSTANCE shdoclc = NULL;
62 static WCHAR *status_strings[IDS_STATUS_LAST-IDS_STATUS_FIRST+1];
63 static IMultiLanguage2 *mlang;
64 static IInternetSecurityManager *security_manager;
65 static unsigned global_max_compat_mode = COMPAT_MODE_IE11;
66 static struct list compat_config = LIST_INIT(compat_config);
68 typedef struct {
69 struct list entry;
70 compat_mode_t max_compat_mode;
71 WCHAR host[1];
72 } compat_config_t;
74 static BOOL ensure_mlang(void)
76 IMultiLanguage2 *new_mlang;
77 HRESULT hres;
79 if(mlang)
80 return TRUE;
82 hres = CoCreateInstance(&CLSID_CMultiLanguage, NULL, CLSCTX_INPROC_SERVER,
83 &IID_IMultiLanguage2, (void**)&new_mlang);
84 if(FAILED(hres)) {
85 ERR("Could not create CMultiLanguage instance\n");
86 return FALSE;
89 if(InterlockedCompareExchangePointer((void**)&mlang, new_mlang, NULL))
90 IMultiLanguage2_Release(new_mlang);
92 return TRUE;
95 UINT cp_from_charset_string(BSTR charset)
97 MIMECSETINFO info;
98 HRESULT hres;
100 if(!ensure_mlang())
101 return CP_UTF8;
103 hres = IMultiLanguage2_GetCharsetInfo(mlang, charset, &info);
104 if(FAILED(hres)) {
105 FIXME("GetCharsetInfo failed: %08x\n", hres);
106 return CP_UTF8;
109 return info.uiInternetEncoding;
112 BSTR charset_string_from_cp(UINT cp)
114 MIMECPINFO info;
115 HRESULT hres;
117 if(!ensure_mlang())
118 return SysAllocString(NULL);
120 hres = IMultiLanguage2_GetCodePageInfo(mlang, cp, GetUserDefaultUILanguage(), &info);
121 if(FAILED(hres)) {
122 ERR("GetCodePageInfo failed: %08x\n", hres);
123 return SysAllocString(NULL);
126 return SysAllocString(info.wszWebCharset);
129 IInternetSecurityManager *get_security_manager(void)
131 if(!security_manager) {
132 IInternetSecurityManager *manager;
133 HRESULT hres;
135 hres = CoInternetCreateSecurityManager(NULL, &manager, 0);
136 if(FAILED(hres))
137 return NULL;
139 if(InterlockedCompareExchangePointer((void**)&security_manager, manager, NULL))
140 IInternetSecurityManager_Release(manager);
143 return security_manager;
146 static BOOL read_compat_mode(HKEY key, compat_mode_t *r)
148 WCHAR version[32];
149 DWORD type, size;
150 LSTATUS status;
152 size = sizeof(version);
153 status = RegQueryValueExW(key, L"MaxCompatMode", NULL, &type, (BYTE*)version, &size);
154 if(status != ERROR_SUCCESS || type != REG_SZ)
155 return FALSE;
157 return parse_compat_version(version, r);
160 static BOOL WINAPI load_compat_settings(INIT_ONCE *once, void *param, void **context)
162 WCHAR key_name[INTERNET_MAX_HOST_NAME_LENGTH];
163 DWORD index = 0, name_size;
164 compat_config_t *new_entry;
165 compat_mode_t max_compat_mode;
166 HKEY key, host_key;
167 DWORD res;
169 /* @@ Wine registry key: HKCU\Software\Wine\MSHTML\CompatMode */
170 res = RegOpenKeyW(HKEY_CURRENT_USER, L"Software\\Wine\\MSHTML\\CompatMode", &key);
171 if(res != ERROR_SUCCESS)
172 return TRUE;
174 if(read_compat_mode(key, &max_compat_mode)) {
175 TRACE("Setting global max compat mode to %u\n", max_compat_mode);
176 global_max_compat_mode = max_compat_mode;
179 while(1) {
180 res = RegEnumKeyW(key, index, key_name, ARRAY_SIZE(key_name));
181 if(res == ERROR_NO_MORE_ITEMS)
182 break;
183 index++;
184 if(res != ERROR_SUCCESS) {
185 WARN("RegEnumKey failed: %u\n", GetLastError());
186 continue;
189 name_size = lstrlenW(key_name) + 1;
190 new_entry = heap_alloc(FIELD_OFFSET(compat_config_t, host[name_size]));
191 if(!new_entry)
192 continue;
194 new_entry->max_compat_mode = COMPAT_MODE_IE11;
195 memcpy(new_entry->host, key_name, name_size * sizeof(WCHAR));
196 list_add_tail(&compat_config, &new_entry->entry);
198 res = RegOpenKeyW(key, key_name, &host_key);
199 if(res != ERROR_SUCCESS)
200 continue;
202 if(read_compat_mode(host_key, &max_compat_mode)) {
203 TRACE("Setting max compat mode for %s to %u\n", debugstr_w(key_name), max_compat_mode);
204 new_entry->max_compat_mode = max_compat_mode;
207 RegCloseKey(host_key);
210 RegCloseKey(key);
211 return TRUE;
214 compat_mode_t get_max_compat_mode(IUri *uri)
216 compat_config_t *iter;
217 size_t len, iter_len;
218 BSTR host;
219 HRESULT hres;
221 static INIT_ONCE init_once = INIT_ONCE_STATIC_INIT;
222 InitOnceExecuteOnce(&init_once, load_compat_settings, NULL, NULL);
224 if(!uri)
225 return global_max_compat_mode;
226 hres = IUri_GetHost(uri, &host);
227 if(FAILED(hres))
228 return global_max_compat_mode;
229 len = SysStringLen(host);
231 LIST_FOR_EACH_ENTRY(iter, &compat_config, compat_config_t, entry) {
232 iter_len = lstrlenW(iter->host);
233 /* If configured host starts with '.', we also match subdomains */
234 if((len == iter_len || (iter->host[0] == '.' && len > iter_len))
235 && !memcmp(host + len - iter_len, iter->host, iter_len * sizeof(WCHAR))) {
236 TRACE("Found max mode %u\n", iter->max_compat_mode);
237 return iter->max_compat_mode;
241 SysFreeString(host);
242 TRACE("Using global max mode %u\n", global_max_compat_mode);
243 return global_max_compat_mode;
246 static void thread_detach(void)
248 thread_data_t *thread_data;
250 thread_data = get_thread_data(FALSE);
251 if(!thread_data)
252 return;
254 if(thread_data->thread_hwnd)
255 DestroyWindow(thread_data->thread_hwnd);
257 heap_free(thread_data);
260 static void free_strings(void)
262 unsigned int i;
263 for(i = 0; i < ARRAY_SIZE(status_strings); i++)
264 heap_free(status_strings[i]);
267 static void process_detach(void)
269 compat_config_t *config;
271 close_gecko();
272 release_typelib();
274 while(!list_empty(&compat_config)) {
275 config = LIST_ENTRY(list_head(&compat_config), compat_config_t, entry);
276 list_remove(&config->entry);
277 heap_free(config);
280 if(shdoclc)
281 FreeLibrary(shdoclc);
282 if(mshtml_tls != TLS_OUT_OF_INDEXES)
283 TlsFree(mshtml_tls);
284 if(mlang)
285 IMultiLanguage2_Release(mlang);
286 if(security_manager)
287 IInternetSecurityManager_Release(security_manager);
289 free_strings();
292 void set_statustext(HTMLDocumentObj* doc, INT id, LPCWSTR arg)
294 int index = id - IDS_STATUS_FIRST;
295 WCHAR *p = status_strings[index];
296 DWORD len;
298 if(!doc->frame)
299 return;
301 if(!p) {
302 len = 255;
303 p = heap_alloc(len * sizeof(WCHAR));
304 len = LoadStringW(hInst, id, p, len) + 1;
305 p = heap_realloc(p, len * sizeof(WCHAR));
306 if(InterlockedCompareExchangePointer((void**)&status_strings[index], p, NULL)) {
307 heap_free(p);
308 p = status_strings[index];
312 if(arg) {
313 WCHAR *buf;
315 len = lstrlenW(p) + lstrlenW(arg) - 1;
316 buf = heap_alloc(len * sizeof(WCHAR));
318 swprintf(buf, len, p, arg);
320 p = buf;
323 IOleInPlaceFrame_SetStatusText(doc->frame, p);
325 if(arg)
326 heap_free(p);
329 HRESULT do_query_service(IUnknown *unk, REFGUID guid_service, REFIID riid, void **ppv)
331 IServiceProvider *sp;
332 HRESULT hres;
334 hres = IUnknown_QueryInterface(unk, &IID_IServiceProvider, (void**)&sp);
335 if(FAILED(hres))
336 return hres;
338 hres = IServiceProvider_QueryService(sp, guid_service, riid, ppv);
339 IServiceProvider_Release(sp);
340 return hres;
343 HINSTANCE get_shdoclc(void)
345 if(shdoclc)
346 return shdoclc;
348 return shdoclc = LoadLibraryExW(L"shdoclc.dll", NULL, LOAD_LIBRARY_AS_DATAFILE);
351 BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID reserved)
353 switch(fdwReason) {
354 case DLL_PROCESS_ATTACH:
355 hInst = hInstDLL;
356 break;
357 case DLL_PROCESS_DETACH:
358 if (reserved) break;
359 process_detach();
360 break;
361 case DLL_THREAD_DETACH:
362 thread_detach();
363 break;
365 return TRUE;
368 /***********************************************************
369 * ClassFactory implementation
371 typedef HRESULT (*CreateInstanceFunc)(IUnknown*,REFIID,void**);
372 typedef struct {
373 IClassFactory IClassFactory_iface;
374 LONG ref;
375 CreateInstanceFunc fnCreateInstance;
376 } ClassFactory;
378 static inline ClassFactory *impl_from_IClassFactory(IClassFactory *iface)
380 return CONTAINING_RECORD(iface, ClassFactory, IClassFactory_iface);
383 static HRESULT WINAPI ClassFactory_QueryInterface(IClassFactory *iface, REFGUID riid, void **ppvObject)
385 if(IsEqualGUID(&IID_IClassFactory, riid) || IsEqualGUID(&IID_IUnknown, riid)) {
386 IClassFactory_AddRef(iface);
387 *ppvObject = iface;
388 return S_OK;
391 WARN("not supported iid %s\n", debugstr_mshtml_guid(riid));
392 *ppvObject = NULL;
393 return E_NOINTERFACE;
396 static ULONG WINAPI ClassFactory_AddRef(IClassFactory *iface)
398 ClassFactory *This = impl_from_IClassFactory(iface);
399 ULONG ref = InterlockedIncrement(&This->ref);
400 TRACE("(%p) ref = %u\n", This, ref);
401 return ref;
404 static ULONG WINAPI ClassFactory_Release(IClassFactory *iface)
406 ClassFactory *This = impl_from_IClassFactory(iface);
407 ULONG ref = InterlockedDecrement(&This->ref);
409 TRACE("(%p) ref = %u\n", This, ref);
411 if(!ref) {
412 heap_free(This);
415 return ref;
418 static HRESULT WINAPI ClassFactory_CreateInstance(IClassFactory *iface, IUnknown *pUnkOuter,
419 REFIID riid, void **ppvObject)
421 ClassFactory *This = impl_from_IClassFactory(iface);
422 return This->fnCreateInstance(pUnkOuter, riid, ppvObject);
425 static HRESULT WINAPI ClassFactory_LockServer(IClassFactory *iface, BOOL dolock)
427 TRACE("(%p)->(%x)\n", iface, dolock);
429 /* We never unload the DLL. See DllCanUnloadNow(). */
430 return S_OK;
433 static const IClassFactoryVtbl HTMLClassFactoryVtbl = {
434 ClassFactory_QueryInterface,
435 ClassFactory_AddRef,
436 ClassFactory_Release,
437 ClassFactory_CreateInstance,
438 ClassFactory_LockServer
441 static HRESULT ClassFactory_Create(REFIID riid, void **ppv, CreateInstanceFunc fnCreateInstance)
443 ClassFactory *ret = heap_alloc(sizeof(ClassFactory));
444 HRESULT hres;
446 ret->IClassFactory_iface.lpVtbl = &HTMLClassFactoryVtbl;
447 ret->ref = 0;
448 ret->fnCreateInstance = fnCreateInstance;
450 hres = IClassFactory_QueryInterface(&ret->IClassFactory_iface, riid, ppv);
451 if(FAILED(hres)) {
452 heap_free(ret);
453 *ppv = NULL;
455 return hres;
458 /******************************************************************
459 * DllGetClassObject (MSHTML.@)
461 HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv)
463 if(IsEqualGUID(&CLSID_HTMLDocument, rclsid)) {
464 TRACE("(CLSID_HTMLDocument %s %p)\n", debugstr_mshtml_guid(riid), ppv);
465 return ClassFactory_Create(riid, ppv, HTMLDocument_Create);
466 }else if(IsEqualGUID(&CLSID_MHTMLDocument, rclsid)) {
467 TRACE("(CLSID_MHTMLDocument %s %p)\n", debugstr_mshtml_guid(riid), ppv);
468 return ClassFactory_Create(riid, ppv, MHTMLDocument_Create);
469 }else if(IsEqualGUID(&CLSID_AboutProtocol, rclsid)) {
470 TRACE("(CLSID_AboutProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
471 return ProtocolFactory_Create(rclsid, riid, ppv);
472 }else if(IsEqualGUID(&CLSID_JSProtocol, rclsid)) {
473 TRACE("(CLSID_JSProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
474 return ProtocolFactory_Create(rclsid, riid, ppv);
475 }else if(IsEqualGUID(&CLSID_MailtoProtocol, rclsid)) {
476 TRACE("(CLSID_MailtoProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
477 return ProtocolFactory_Create(rclsid, riid, ppv);
478 }else if(IsEqualGUID(&CLSID_ResProtocol, rclsid)) {
479 TRACE("(CLSID_ResProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
480 return ProtocolFactory_Create(rclsid, riid, ppv);
481 }else if(IsEqualGUID(&CLSID_SysimageProtocol, rclsid)) {
482 TRACE("(CLSID_SysimageProtocol %s %p)\n", debugstr_mshtml_guid(riid), ppv);
483 return ProtocolFactory_Create(rclsid, riid, ppv);
484 }else if(IsEqualGUID(&CLSID_HTMLLoadOptions, rclsid)) {
485 TRACE("(CLSID_HTMLLoadOptions %s %p)\n", debugstr_mshtml_guid(riid), ppv);
486 return ClassFactory_Create(riid, ppv, HTMLLoadOptions_Create);
489 FIXME("Unknown class %s\n", debugstr_guid(rclsid));
490 return CLASS_E_CLASSNOTAVAILABLE;
493 /******************************************************************
494 * DllCanUnloadNow (MSHTML.@)
496 HRESULT WINAPI DllCanUnloadNow(void)
498 TRACE("()\n");
499 /* The cost of keeping this DLL in memory is small. */
500 return S_FALSE;
503 /***********************************************************************
504 * RunHTMLApplication (MSHTML.@)
506 * Appears to have the same prototype as WinMain.
508 HRESULT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst,
509 LPSTR szCmdLine, INT nCmdShow )
511 FIXME("%p %p %s %d\n", hinst, hPrevInst, debugstr_a(szCmdLine), nCmdShow );
512 return S_OK;
515 /***********************************************************************
516 * RNIGetCompatibleVersion (MSHTML.@)
518 DWORD WINAPI RNIGetCompatibleVersion(void)
520 TRACE("()\n");
521 return 0x20000;
524 /***********************************************************************
525 * DllInstall (MSHTML.@)
527 HRESULT WINAPI DllInstall(BOOL install, const WCHAR *cmdline)
529 TRACE("(%x %s)\n", install, debugstr_w(cmdline));
531 if(cmdline && *cmdline)
532 FIXME("unsupported cmdline: %s\n", debugstr_w(cmdline));
533 else if(install)
534 load_gecko();
536 return S_OK;
539 /***********************************************************************
540 * ShowHTMLDialog (MSHTML.@)
542 HRESULT WINAPI ShowHTMLDialog(HWND hwndParent, IMoniker *pMk, VARIANT *pvarArgIn,
543 WCHAR *pchOptions, VARIANT *pvarArgOut)
545 FIXME("(%p %p %p %s %p)\n", hwndParent, pMk, pvarArgIn, debugstr_w(pchOptions), pvarArgOut);
546 return E_NOTIMPL;
549 /***********************************************************************
550 * PrintHTML (MSHTML.@)
552 void WINAPI PrintHTML(HWND hwnd, HINSTANCE handle, LPCSTR cmdline, INT show)
554 FIXME("(%p %p %s %x)\n", hwnd, handle, debugstr_a(cmdline), show);
557 DEFINE_GUID(CLSID_CBackgroundPropertyPage, 0x3050F232, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
558 DEFINE_GUID(CLSID_CCDAnchorPropertyPage, 0x3050F1FC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
559 DEFINE_GUID(CLSID_CCDGenericPropertyPage, 0x3050F17F, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
560 DEFINE_GUID(CLSID_CDwnBindInfo, 0x3050F3C2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
561 DEFINE_GUID(CLSID_CHiFiUses, 0x5AAF51B3, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
562 DEFINE_GUID(CLSID_CHtmlComponentConstructor, 0x3050F4F8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
563 DEFINE_GUID(CLSID_CInlineStylePropertyPage, 0x3050F296, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
564 DEFINE_GUID(CLSID_CPeerHandler, 0x5AAF51B2, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
565 DEFINE_GUID(CLSID_CRecalcEngine, 0x3050F499, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
566 DEFINE_GUID(CLSID_CSvrOMUses, 0x3050F4F0, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
567 DEFINE_GUID(CLSID_CrSource, 0x65014010, 0x9F62, 0x11D1, 0xA6,0x51, 0x00,0x60,0x08,0x11,0xD5,0xCE);
568 DEFINE_GUID(CLSID_ExternalFrameworkSite, 0x3050F163, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
569 DEFINE_GUID(CLSID_HTADocument, 0x3050F5C8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
570 DEFINE_GUID(CLSID_HTMLPluginDocument, 0x25336921, 0x03F9, 0x11CF, 0x8F,0xD0, 0x00,0xAA,0x00,0x68,0x6F,0x13);
571 DEFINE_GUID(CLSID_HTMLPopup, 0x3050F667, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
572 DEFINE_GUID(CLSID_HTMLPopupDoc, 0x3050F67D, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
573 DEFINE_GUID(CLSID_HTMLServerDoc, 0x3050F4E7, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
574 DEFINE_GUID(CLSID_IImageDecodeFilter, 0x607FD4E8, 0x0A03, 0x11D1, 0xAB,0x1D, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
575 DEFINE_GUID(CLSID_IImgCtx, 0x3050F3D6, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
576 DEFINE_GUID(CLSID_IntDitherer, 0x05F6FE1A, 0xECEF, 0x11D0, 0xAA,0xE7, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
577 DEFINE_GUID(CLSID_TridentAPI, 0x429AF92C, 0xA51F, 0x11D2, 0x86,0x1E, 0x00,0xC0,0x4F,0xA3,0x5C,0x89);
579 #define INF_SET_ID(id) \
580 do \
582 static CHAR name[] = #id; \
584 pse[i].pszName = name; \
585 clsids[i++] = &id; \
586 } while (0)
588 #define INF_SET_CLSID(clsid) INF_SET_ID(CLSID_ ## clsid)
590 static HRESULT register_server(BOOL do_register)
592 HRESULT hres;
593 HMODULE hAdvpack;
594 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
595 STRTABLEA strtable;
596 STRENTRYA pse[35];
597 static CLSID const *clsids[35];
598 unsigned int i = 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(L"advpack.dll");
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 return hres;
681 /***********************************************************************
682 * DllUnregisterServer (MSHTML.@)
684 HRESULT WINAPI DllUnregisterServer(void)
686 HRESULT hres = __wine_unregister_resources( hInst );
687 if(SUCCEEDED(hres)) hres = register_server(FALSE);
688 return hres;
691 const char *debugstr_mshtml_guid(const GUID *iid)
693 #define X(x) if(IsEqualGUID(iid, &x)) return #x
694 X(DIID_HTMLDocumentEvents);
695 X(DIID_HTMLDocumentEvents2);
696 X(DIID_HTMLTableEvents);
697 X(DIID_HTMLTextContainerEvents);
698 X(IID_HTMLPluginContainer);
699 X(IID_IConnectionPoint);
700 X(IID_IConnectionPointContainer);
701 X(IID_ICustomDoc);
702 X(IID_IDispatch);
703 X(IID_IDispatchEx);
704 X(IID_IDispatchJS);
705 X(IID_IDisplayServices);
706 X(IID_UndocumentedScriptIface);
707 X(IID_IEnumConnections);
708 X(IID_IEnumVARIANT);
709 X(IID_IHlinkTarget);
710 X(IID_IHTMLDocument6);
711 X(IID_IHTMLDocument7);
712 X(IID_IHTMLEditServices);
713 X(IID_IHTMLFramesCollection2);
714 X(IID_IHTMLPrivateWindow);
715 X(IID_IHtmlLoadOptions);
716 X(IID_IInternetHostSecurityManager);
717 X(IID_IInternetProtocol);
718 X(IID_IInternetProtocolRoot);
719 X(IID_IManagedObject);
720 X(IID_IMarkupContainer);
721 X(IID_IMarkupServices);
722 X(IID_IMarshal);
723 X(IID_IMonikerProp);
724 X(IID_IObjectIdentity);
725 X(IID_IObjectSafety);
726 X(IID_IObjectWithSite);
727 X(IID_IOleContainer);
728 X(IID_IOleCommandTarget);
729 X(IID_IOleControl);
730 X(IID_IOleDocument);
731 X(IID_IOleDocumentView);
732 X(IID_IOleInPlaceActiveObject);
733 X(IID_IOleInPlaceFrame);
734 X(IID_IOleInPlaceObject);
735 X(IID_IOleInPlaceObjectWindowless);
736 X(IID_IOleInPlaceUIWindow);
737 X(IID_IOleObject);
738 X(IID_IOleWindow);
739 X(IID_IOptionArray);
740 X(IID_IPersist);
741 X(IID_IPersistFile);
742 X(IID_IPersistHistory);
743 X(IID_IPersistMoniker);
744 X(IID_IPersistStreamInit);
745 X(IID_IPropertyNotifySink);
746 X(IID_IProvideClassInfo);
747 X(IID_IProvideClassInfo2);
748 X(IID_IProvideMultipleClassInfo);
749 X(IID_IServiceProvider);
750 X(IID_ISupportErrorInfo);
751 X(IID_ITargetContainer);
752 X(IID_ITravelLogClient);
753 X(IID_IUnknown);
754 X(IID_IViewObject);
755 X(IID_IViewObject2);
756 X(IID_IViewObjectEx);
757 X(IID_nsCycleCollectionISupports);
758 X(IID_nsXPCOMCycleCollectionParticipant);
759 #define XIID(x) X(IID_##x);
760 #define XDIID(x) X(DIID_##x);
761 TID_LIST
762 #undef XIID
763 #undef XDIID
764 #undef X
766 return debugstr_guid(iid);