nsiproxy: Introduce IOCTL_NSIPROXY_WINE_GET_ALL_PARAMETERS.
[wine.git] / dlls / mshtml / main.c
blob959d2d6621432cf85e1f8182d091413e0b2cd6ae
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 * RunHTMLApplication (MSHTML.@)
496 * Appears to have the same prototype as WinMain.
498 HRESULT WINAPI RunHTMLApplication( HINSTANCE hinst, HINSTANCE hPrevInst,
499 LPSTR szCmdLine, INT nCmdShow )
501 FIXME("%p %p %s %d\n", hinst, hPrevInst, debugstr_a(szCmdLine), nCmdShow );
502 return S_OK;
505 /***********************************************************************
506 * RNIGetCompatibleVersion (MSHTML.@)
508 DWORD WINAPI RNIGetCompatibleVersion(void)
510 TRACE("()\n");
511 return 0x20000;
514 /***********************************************************************
515 * DllInstall (MSHTML.@)
517 HRESULT WINAPI DllInstall(BOOL install, const WCHAR *cmdline)
519 TRACE("(%x %s)\n", install, debugstr_w(cmdline));
521 if(cmdline && *cmdline)
522 FIXME("unsupported cmdline: %s\n", debugstr_w(cmdline));
523 else if(install)
524 load_gecko();
526 return S_OK;
529 /***********************************************************************
530 * ShowHTMLDialog (MSHTML.@)
532 HRESULT WINAPI ShowHTMLDialog(HWND hwndParent, IMoniker *pMk, VARIANT *pvarArgIn,
533 WCHAR *pchOptions, VARIANT *pvarArgOut)
535 FIXME("(%p %p %p %s %p)\n", hwndParent, pMk, pvarArgIn, debugstr_w(pchOptions), pvarArgOut);
536 return E_NOTIMPL;
539 /***********************************************************************
540 * PrintHTML (MSHTML.@)
542 void WINAPI PrintHTML(HWND hwnd, HINSTANCE handle, LPCSTR cmdline, INT show)
544 FIXME("(%p %p %s %x)\n", hwnd, handle, debugstr_a(cmdline), show);
547 DEFINE_GUID(CLSID_CBackgroundPropertyPage, 0x3050F232, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
548 DEFINE_GUID(CLSID_CCDAnchorPropertyPage, 0x3050F1FC, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
549 DEFINE_GUID(CLSID_CCDGenericPropertyPage, 0x3050F17F, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
550 DEFINE_GUID(CLSID_CDwnBindInfo, 0x3050F3C2, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
551 DEFINE_GUID(CLSID_CHiFiUses, 0x5AAF51B3, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
552 DEFINE_GUID(CLSID_CHtmlComponentConstructor, 0x3050F4F8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
553 DEFINE_GUID(CLSID_CInlineStylePropertyPage, 0x3050F296, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
554 DEFINE_GUID(CLSID_CPeerHandler, 0x5AAF51B2, 0xB1F0, 0x11D1, 0xB6,0xAB, 0x00,0xA0,0xC9,0x08,0x33,0xE9);
555 DEFINE_GUID(CLSID_CRecalcEngine, 0x3050F499, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
556 DEFINE_GUID(CLSID_CSvrOMUses, 0x3050F4F0, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
557 DEFINE_GUID(CLSID_CrSource, 0x65014010, 0x9F62, 0x11D1, 0xA6,0x51, 0x00,0x60,0x08,0x11,0xD5,0xCE);
558 DEFINE_GUID(CLSID_ExternalFrameworkSite, 0x3050F163, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
559 DEFINE_GUID(CLSID_HTADocument, 0x3050F5C8, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
560 DEFINE_GUID(CLSID_HTMLPluginDocument, 0x25336921, 0x03F9, 0x11CF, 0x8F,0xD0, 0x00,0xAA,0x00,0x68,0x6F,0x13);
561 DEFINE_GUID(CLSID_HTMLPopup, 0x3050F667, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
562 DEFINE_GUID(CLSID_HTMLPopupDoc, 0x3050F67D, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
563 DEFINE_GUID(CLSID_HTMLServerDoc, 0x3050F4E7, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
564 DEFINE_GUID(CLSID_IImageDecodeFilter, 0x607FD4E8, 0x0A03, 0x11D1, 0xAB,0x1D, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
565 DEFINE_GUID(CLSID_IImgCtx, 0x3050F3D6, 0x98B5, 0x11CF, 0xBB,0x82, 0x00,0xAA,0x00,0xBD,0xCE,0x0B);
566 DEFINE_GUID(CLSID_IntDitherer, 0x05F6FE1A, 0xECEF, 0x11D0, 0xAA,0xE7, 0x00,0xC0,0x4F,0xC9,0xB3,0x04);
567 DEFINE_GUID(CLSID_TridentAPI, 0x429AF92C, 0xA51F, 0x11D2, 0x86,0x1E, 0x00,0xC0,0x4F,0xA3,0x5C,0x89);
569 #define INF_SET_ID(id) \
570 do \
572 static CHAR name[] = #id; \
574 pse[i].pszName = name; \
575 clsids[i++] = &id; \
576 } while (0)
578 #define INF_SET_CLSID(clsid) INF_SET_ID(CLSID_ ## clsid)
580 static HRESULT register_server(BOOL do_register)
582 HRESULT hres;
583 HMODULE hAdvpack;
584 HRESULT (WINAPI *pRegInstall)(HMODULE hm, LPCSTR pszSection, const STRTABLEA* pstTable);
585 STRTABLEA strtable;
586 STRENTRYA pse[35];
587 static CLSID const *clsids[35];
588 unsigned int i = 0;
590 TRACE("(%x)\n", do_register);
592 INF_SET_CLSID(AboutProtocol);
593 INF_SET_CLSID(CAnchorBrowsePropertyPage);
594 INF_SET_CLSID(CBackgroundPropertyPage);
595 INF_SET_CLSID(CCDAnchorPropertyPage);
596 INF_SET_CLSID(CCDGenericPropertyPage);
597 INF_SET_CLSID(CDocBrowsePropertyPage);
598 INF_SET_CLSID(CDwnBindInfo);
599 INF_SET_CLSID(CHiFiUses);
600 INF_SET_CLSID(CHtmlComponentConstructor);
601 INF_SET_CLSID(CImageBrowsePropertyPage);
602 INF_SET_CLSID(CInlineStylePropertyPage);
603 INF_SET_CLSID(CPeerHandler);
604 INF_SET_CLSID(CRecalcEngine);
605 INF_SET_CLSID(CSvrOMUses);
606 INF_SET_CLSID(CrSource);
607 INF_SET_CLSID(ExternalFrameworkSite);
608 INF_SET_CLSID(HTADocument);
609 INF_SET_CLSID(HTMLDocument);
610 INF_SET_CLSID(HTMLLoadOptions);
611 INF_SET_CLSID(HTMLPluginDocument);
612 INF_SET_CLSID(HTMLPopup);
613 INF_SET_CLSID(HTMLPopupDoc);
614 INF_SET_CLSID(HTMLServerDoc);
615 INF_SET_CLSID(HTMLWindowProxy);
616 INF_SET_CLSID(IImageDecodeFilter);
617 INF_SET_CLSID(IImgCtx);
618 INF_SET_CLSID(IntDitherer);
619 INF_SET_CLSID(JSProtocol);
620 INF_SET_CLSID(MHTMLDocument);
621 INF_SET_CLSID(MailtoProtocol);
622 INF_SET_CLSID(ResProtocol);
623 INF_SET_CLSID(Scriptlet);
624 INF_SET_CLSID(SysimageProtocol);
625 INF_SET_CLSID(TridentAPI);
626 INF_SET_ID(LIBID_MSHTML);
628 for(i=0; i < ARRAY_SIZE(pse); i++) {
629 pse[i].pszValue = heap_alloc(39);
630 sprintf(pse[i].pszValue, "{%08X-%04X-%04X-%02X%02X-%02X%02X%02X%02X%02X%02X}",
631 clsids[i]->Data1, clsids[i]->Data2, clsids[i]->Data3, clsids[i]->Data4[0],
632 clsids[i]->Data4[1], clsids[i]->Data4[2], clsids[i]->Data4[3], clsids[i]->Data4[4],
633 clsids[i]->Data4[5], clsids[i]->Data4[6], clsids[i]->Data4[7]);
636 strtable.cEntries = ARRAY_SIZE(pse);
637 strtable.pse = pse;
639 hAdvpack = LoadLibraryW(L"advpack.dll");
640 pRegInstall = (void *)GetProcAddress(hAdvpack, "RegInstall");
642 hres = pRegInstall(hInst, do_register ? "RegisterDll" : "UnregisterDll", &strtable);
644 FreeLibrary(hAdvpack);
646 for(i=0; i < ARRAY_SIZE(pse); i++)
647 heap_free(pse[i].pszValue);
649 if(FAILED(hres))
650 ERR("RegInstall failed: %08x\n", hres);
652 return hres;
655 #undef INF_SET_CLSID
656 #undef INF_SET_ID
658 /***********************************************************************
659 * DllRegisterServer (MSHTML.@)
661 HRESULT WINAPI DllRegisterServer(void)
663 HRESULT hres;
665 hres = __wine_register_resources();
666 if(SUCCEEDED(hres))
667 hres = register_server(TRUE);
668 return hres;
671 /***********************************************************************
672 * DllUnregisterServer (MSHTML.@)
674 HRESULT WINAPI DllUnregisterServer(void)
676 HRESULT hres = __wine_unregister_resources();
677 if(SUCCEEDED(hres)) hres = register_server(FALSE);
678 return hres;
681 const char *debugstr_mshtml_guid(const GUID *iid)
683 #define X(x) if(IsEqualGUID(iid, &x)) return #x
684 X(DIID_HTMLDocumentEvents);
685 X(DIID_HTMLDocumentEvents2);
686 X(DIID_HTMLTableEvents);
687 X(DIID_HTMLTextContainerEvents);
688 X(IID_HTMLPluginContainer);
689 X(IID_IConnectionPoint);
690 X(IID_IConnectionPointContainer);
691 X(IID_ICustomDoc);
692 X(IID_IDispatch);
693 X(IID_IDispatchEx);
694 X(IID_IDispatchJS);
695 X(IID_IDisplayServices);
696 X(IID_UndocumentedScriptIface);
697 X(IID_IEnumConnections);
698 X(IID_IEnumVARIANT);
699 X(IID_IHlinkTarget);
700 X(IID_IHTMLDocument6);
701 X(IID_IHTMLDocument7);
702 X(IID_IHTMLEditServices);
703 X(IID_IHTMLFramesCollection2);
704 X(IID_IHTMLPrivateWindow);
705 X(IID_IHtmlLoadOptions);
706 X(IID_IInternetHostSecurityManager);
707 X(IID_IInternetProtocol);
708 X(IID_IInternetProtocolRoot);
709 X(IID_IManagedObject);
710 X(IID_IMarkupContainer);
711 X(IID_IMarkupServices);
712 X(IID_IMarshal);
713 X(IID_IMonikerProp);
714 X(IID_IObjectIdentity);
715 X(IID_IObjectSafety);
716 X(IID_IObjectWithSite);
717 X(IID_IOleContainer);
718 X(IID_IOleCommandTarget);
719 X(IID_IOleControl);
720 X(IID_IOleDocument);
721 X(IID_IOleDocumentView);
722 X(IID_IOleInPlaceActiveObject);
723 X(IID_IOleInPlaceFrame);
724 X(IID_IOleInPlaceObject);
725 X(IID_IOleInPlaceObjectWindowless);
726 X(IID_IOleInPlaceUIWindow);
727 X(IID_IOleObject);
728 X(IID_IOleWindow);
729 X(IID_IOptionArray);
730 X(IID_IPersist);
731 X(IID_IPersistFile);
732 X(IID_IPersistHistory);
733 X(IID_IPersistMoniker);
734 X(IID_IPersistStreamInit);
735 X(IID_IPropertyNotifySink);
736 X(IID_IProvideClassInfo);
737 X(IID_IProvideClassInfo2);
738 X(IID_IProvideMultipleClassInfo);
739 X(IID_IServiceProvider);
740 X(IID_ISupportErrorInfo);
741 X(IID_ITargetContainer);
742 X(IID_ITravelLogClient);
743 X(IID_IUnknown);
744 X(IID_IViewObject);
745 X(IID_IViewObject2);
746 X(IID_IViewObjectEx);
747 X(IID_nsCycleCollectionISupports);
748 X(IID_nsXPCOMCycleCollectionParticipant);
749 #define XIID(x) X(IID_##x);
750 #define XDIID(x) X(DIID_##x);
751 TID_LIST
752 #undef XIID
753 #undef XDIID
754 #undef X
756 return debugstr_guid(iid);