From a1cce9288bb325a21fcd15bfe10ec254534e8388 Mon Sep 17 00:00:00 2001 From: Alistair Leslie-Hughes Date: Wed, 12 Mar 2008 20:09:32 +1100 Subject: [PATCH] msxml3: Register msxml3 typelib. --- dlls/msxml3/main.c | 38 +++++++++++++++++++++++++++++++++++++- dlls/msxml3/msxml_private.h | 1 + dlls/msxml3/regsvr.c | 18 ++++++++++++++++++ 3 files changed, 56 insertions(+), 1 deletion(-) diff --git a/dlls/msxml3/main.c b/dlls/msxml3/main.c index 92e9dbb017f..abbe040ea3e 100644 --- a/dlls/msxml3/main.c +++ b/dlls/msxml3/main.c @@ -37,7 +37,7 @@ WINE_DEFAULT_DEBUG_CHANNEL(msxml); - +static HINSTANCE hInstance; static ITypeLib *typelib; static ITypeInfo *typeinfos[LAST_tid]; @@ -96,6 +96,41 @@ HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo) return S_OK; } +static CRITICAL_SECTION MSXML3_typelib_cs; +static CRITICAL_SECTION_DEBUG MSXML3_typelib_cs_debug = +{ + 0, 0, &MSXML3_typelib_cs, + { &MSXML3_typelib_cs_debug.ProcessLocksList, + &MSXML3_typelib_cs_debug.ProcessLocksList }, + 0, 0, { (DWORD_PTR)(__FILE__ ": MSXML3_typelib_cs") } +}; +static CRITICAL_SECTION MSXML3_typelib_cs = { &MSXML3_typelib_cs_debug, -1, 0, 0, 0, 0 }; + +ITypeLib *get_msxml3_typelib( LPWSTR *path ) +{ + static WCHAR msxml3_path[MAX_PATH]; + + EnterCriticalSection( &MSXML3_typelib_cs ); + + if (!typelib) + { + TRACE("loading typelib\n"); + + if (GetModuleFileNameW( hInstance, msxml3_path, MAX_PATH )) + LoadTypeLib( msxml3_path, &typelib ); + } + + LeaveCriticalSection( &MSXML3_typelib_cs ); + + if (path) + *path = msxml3_path; + + if (typelib) + ITypeLib_AddRef( typelib ); + + return typelib; +} + static void process_detach(void) { if(typelib) { @@ -123,6 +158,7 @@ BOOL WINAPI DllMain(HINSTANCE hInstDLL, DWORD fdwReason, LPVOID lpv) #ifdef HAVE_LIBXML2 xmlInitParser(); #endif + hInstance = hInstDLL; DisableThreadLibraryCalls(hInstDLL); break; case DLL_PROCESS_DETACH: diff --git a/dlls/msxml3/msxml_private.h b/dlls/msxml3/msxml_private.h index 6feb8ac9bf0..3767686ef62 100644 --- a/dlls/msxml3/msxml_private.h +++ b/dlls/msxml3/msxml_private.h @@ -112,5 +112,6 @@ enum tid_t { }; extern HRESULT get_typeinfo(enum tid_t tid, ITypeInfo **typeinfo); +extern ITypeLib *get_msxml3_typelib( LPWSTR *path ); #endif /* __MSXML_PRIVATE__ */ diff --git a/dlls/msxml3/regsvr.c b/dlls/msxml3/regsvr.c index 3a0c6bd55f3..1f08150d174 100644 --- a/dlls/msxml3/regsvr.c +++ b/dlls/msxml3/regsvr.c @@ -3,6 +3,7 @@ * * Copyright (C) 2003 John K. Hohm * Copyright (C) 2006 Robert Shearman + * Copyright (C) 2008 Alistair Leslie-Hughes * * This library is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -24,6 +25,8 @@ #include #include +#define COBJMACROS + #include "windef.h" #include "winbase.h" #include "winuser.h" @@ -651,6 +654,8 @@ static struct progid const progid_list[] = { HRESULT WINAPI DllRegisterServer(void) { HRESULT hr; + ITypeLib *tl; + LPWSTR path = NULL; TRACE("\n"); @@ -659,6 +664,16 @@ HRESULT WINAPI DllRegisterServer(void) hr = register_interfaces(interface_list); if (SUCCEEDED(hr)) hr = register_progids(progid_list); + + tl = get_msxml3_typelib( &path ); + if (tl) + { + hr = RegisterTypeLib( tl, path, NULL ); + ITypeLib_Release( tl ); + } + else + hr = E_FAIL; + return hr; } @@ -676,5 +691,8 @@ HRESULT WINAPI DllUnregisterServer(void) hr = unregister_interfaces(interface_list); if (SUCCEEDED(hr)) hr = unregister_progids(progid_list); + if (SUCCEEDED(hr)) + hr = UnRegisterTypeLib(&LIBID_MSXML2, 3, 0, LOCALE_SYSTEM_DEFAULT, SYS_WIN32); + return hr; } -- 2.11.4.GIT