[PATCH] Register msxml3 Typelib

Alistair Leslie-Hughes leslie_alistair at hotmail.com
Wed Mar 12 04:09:32 CDT 2008


---
 dlls/msxml3/main.c          |   37 ++++++++++++++++++++++++++++++++++++-
 dlls/msxml3/msxml_private.h |    1 +
 dlls/msxml3/regsvr.c        |   20 +++++++++++++++++++-
 3 files changed, 56 insertions(+), 2 deletions(-)

diff --git a/dlls/msxml3/main.c b/dlls/msxml3/main.c
index 92e9dbb..a8e1b38 100644
--- a/dlls/msxml3/main.c
+++ b/dlls/msxml3/main.c
@@ -37,7 +37,8 @@
 
 WINE_DEFAULT_DEBUG_CHANNEL(msxml);
 
-
+static WCHAR msxml3_path[MAX_PATH];
+HINSTANCE hInstance;
 static ITypeLib *typelib;
 static ITypeInfo *typeinfos[LAST_tid];
 
@@ -96,6 +97,39 @@ 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 )
+{
+    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 +157,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 6feb8ac..3767686 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 3a0c6bd..14f37b5 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 <stdarg.h>
 #include <string.h>
 
+#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;
 }
 
@@ -675,6 +690,9 @@ HRESULT WINAPI DllUnregisterServer(void)
     if (SUCCEEDED(hr))
 	hr = unregister_interfaces(interface_list);
     if (SUCCEEDED(hr))
-	hr = unregister_progids(progid_list);
+	hr = unregister_progids(progid_list);	
+	if (SUCCEEDED(hr))
+	    hr = UnRegisterTypeLib(&LIBID_MSXML2, 3, 0, LOCALE_SYSTEM_DEFAULT, SYS_WIN32);
+	    
     return hr;
 }
-- 
1.5.4.1


--------------000700000104010902000604--




More information about the wine-patches mailing list