Mike McCormack : msi: Register the typelib.
Alexandre Julliard
julliard at wine.codeweavers.com
Thu Feb 8 06:20:22 CST 2007
Module: wine
Branch: master
Commit: 94edfde1d97071b9c4ed3f5ba3e0b043565a2db9
URL: http://source.winehq.org/git/wine.git/?a=commit;h=94edfde1d97071b9c4ed3f5ba3e0b043565a2db9
Author: Mike McCormack <mike at codeweavers.com>
Date: Thu Feb 8 17:20:55 2007 +0900
msi: Register the typelib.
---
dlls/msi/msi_main.c | 45 +++++++++++++++++++++++++++++++++++++++++----
dlls/msi/msipriv.h | 3 +++
dlls/msi/regsvr.c | 15 +++++++++++++++
3 files changed, 59 insertions(+), 4 deletions(-)
diff --git a/dlls/msi/msi_main.c b/dlls/msi/msi_main.c
index 2d82091..a3dac7f 100644
--- a/dlls/msi/msi_main.c
+++ b/dlls/msi/msi_main.c
@@ -27,6 +27,7 @@
#include "winbase.h"
#include "winreg.h"
#include "shlwapi.h"
+#include "oleauto.h"
#include "msipriv.h"
#include "wine/debug.h"
@@ -43,6 +44,8 @@ INSTALLUI_HANDLERW gUIHandlerW = NULL;
DWORD gUIFilter = 0;
LPVOID gUIContext = NULL;
WCHAR gszLogFile[MAX_PATH];
+WCHAR msi_path[MAX_PATH];
+ITypeLib *msi_typelib = NULL;
HINSTANCE msi_hInstance;
/*
@@ -71,6 +74,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,
msi_dialog_register_class();
break;
case DLL_PROCESS_DETACH:
+ if (msi_typelib) ITypeLib_Release( msi_typelib );
msi_dialog_unregister_class();
msi_free_handle_table();
break;
@@ -78,10 +82,38 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL,
return TRUE;
}
-typedef struct tagIClassFactoryImpl {
- const IClassFactoryVtbl *lpVtbl;
- HRESULT (*create_object)( IUnknown*, LPVOID* );
-} IClassFactoryImpl;
+static CRITICAL_SECTION MSI_typelib_cs;
+static CRITICAL_SECTION_DEBUG MSI_typelib_cs_debug =
+{
+ 0, 0, &MSI_typelib_cs,
+ { &MSI_typelib_cs_debug.ProcessLocksList,
+ &MSI_typelib_cs_debug.ProcessLocksList },
+ 0, 0, { (DWORD_PTR)(__FILE__ ": MSI_typelib_cs") }
+};
+static CRITICAL_SECTION MSI_typelib_cs = { &MSI_typelib_cs_debug, -1, 0, 0, 0, 0 };
+
+ITypeLib *get_msi_typelib( LPWSTR *path )
+{
+ EnterCriticalSection( &MSI_typelib_cs );
+
+ if (!msi_typelib)
+ {
+ TRACE("loading typelib\n");
+
+ if (GetModuleFileNameW( msi_hInstance, msi_path, MAX_PATH ))
+ LoadTypeLib( msi_path, &msi_typelib );
+ }
+
+ LeaveCriticalSection( &MSI_typelib_cs );
+
+ if (path)
+ *path = msi_path;
+
+ if (msi_typelib)
+ ITypeLib_AddRef( msi_typelib );
+
+ return msi_typelib;
+}
static HRESULT create_msiserver( IUnknown *pOuter, LPVOID *ppObj )
{
@@ -89,6 +121,11 @@ static HRESULT create_msiserver( IUnknow
return E_FAIL;
}
+typedef struct tagIClassFactoryImpl {
+ const IClassFactoryVtbl *lpVtbl;
+ HRESULT (*create_object)( IUnknown*, LPVOID* );
+} IClassFactoryImpl;
+
static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
REFIID riid,LPVOID *ppobj)
{
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index a89da66..b01bb27 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -525,6 +525,9 @@ typedef struct {
UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
+/* msi server interface */
+extern ITypeLib *get_msi_typelib( LPWSTR *path );
+
/* handle functions */
extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );
diff --git a/dlls/msi/regsvr.c b/dlls/msi/regsvr.c
index dca44e2..6aa73d1 100644
--- a/dlls/msi/regsvr.c
+++ b/dlls/msi/regsvr.c
@@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
+#define COBJMACROS
+
#include "config.h"
#include <stdarg.h>
@@ -31,6 +33,7 @@
#include "ole2.h"
#include "olectl.h"
+#include "oleauto.h"
#include "wine/debug.h"
@@ -650,6 +653,8 @@ static HRESULT register_msiexec(void)
*/
HRESULT WINAPI DllRegisterServer(void)
{
+ LPWSTR path = NULL;
+ ITypeLib *tl;
HRESULT hr;
TRACE("\n");
@@ -659,6 +664,16 @@ HRESULT WINAPI DllRegisterServer(void)
hr = register_interfaces(interface_list);
if (SUCCEEDED(hr))
hr = register_msiexec();
+
+ tl = get_msi_typelib( &path );
+ if (tl)
+ {
+ hr = RegisterTypeLib( tl, path, NULL );
+ ITypeLib_Release( tl );
+ }
+ else
+ hr = E_FAIL;
+
return hr;
}
More information about the wine-cvs
mailing list