msi: Register the typelib.

This commit is contained in:
Mike McCormack 2007-02-08 17:20:55 +09:00 committed by Alexandre Julliard
parent aa28ed0162
commit 94edfde1d9
3 changed files with 59 additions and 4 deletions

View File

@ -27,6 +27,7 @@
#include "winbase.h" #include "winbase.h"
#include "winreg.h" #include "winreg.h"
#include "shlwapi.h" #include "shlwapi.h"
#include "oleauto.h"
#include "msipriv.h" #include "msipriv.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -43,6 +44,8 @@ INSTALLUI_HANDLERW gUIHandlerW = NULL;
DWORD gUIFilter = 0; DWORD gUIFilter = 0;
LPVOID gUIContext = NULL; LPVOID gUIContext = NULL;
WCHAR gszLogFile[MAX_PATH]; WCHAR gszLogFile[MAX_PATH];
WCHAR msi_path[MAX_PATH];
ITypeLib *msi_typelib = NULL;
HINSTANCE msi_hInstance; HINSTANCE msi_hInstance;
/* /*
@ -71,6 +74,7 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
msi_dialog_register_class(); msi_dialog_register_class();
break; break;
case DLL_PROCESS_DETACH: case DLL_PROCESS_DETACH:
if (msi_typelib) ITypeLib_Release( msi_typelib );
msi_dialog_unregister_class(); msi_dialog_unregister_class();
msi_free_handle_table(); msi_free_handle_table();
break; break;
@ -78,10 +82,38 @@ BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
return TRUE; return TRUE;
} }
typedef struct tagIClassFactoryImpl { static CRITICAL_SECTION MSI_typelib_cs;
const IClassFactoryVtbl *lpVtbl; static CRITICAL_SECTION_DEBUG MSI_typelib_cs_debug =
HRESULT (*create_object)( IUnknown*, LPVOID* ); {
} IClassFactoryImpl; 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 ) static HRESULT create_msiserver( IUnknown *pOuter, LPVOID *ppObj )
{ {
@ -89,6 +121,11 @@ static HRESULT create_msiserver( IUnknown *pOuter, LPVOID *ppObj )
return E_FAIL; return E_FAIL;
} }
typedef struct tagIClassFactoryImpl {
const IClassFactoryVtbl *lpVtbl;
HRESULT (*create_object)( IUnknown*, LPVOID* );
} IClassFactoryImpl;
static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface, static HRESULT WINAPI MsiCF_QueryInterface(LPCLASSFACTORY iface,
REFIID riid,LPVOID *ppobj) REFIID riid,LPVOID *ppobj)
{ {

View File

@ -525,6 +525,9 @@ typedef struct {
UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz ); UINT msi_strcpy_to_awstring( LPCWSTR str, awstring *awbuf, DWORD *sz );
/* msi server interface */
extern ITypeLib *get_msi_typelib( LPWSTR *path );
/* handle functions */ /* handle functions */
extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type); extern void *msihandle2msiinfo(MSIHANDLE handle, UINT type);
extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * ); extern MSIHANDLE alloc_msihandle( MSIOBJECTHDR * );

View File

@ -18,6 +18,8 @@
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/ */
#define COBJMACROS
#include "config.h" #include "config.h"
#include <stdarg.h> #include <stdarg.h>
@ -31,6 +33,7 @@
#include "ole2.h" #include "ole2.h"
#include "olectl.h" #include "olectl.h"
#include "oleauto.h"
#include "wine/debug.h" #include "wine/debug.h"
@ -650,6 +653,8 @@ static HRESULT register_msiexec(void)
*/ */
HRESULT WINAPI DllRegisterServer(void) HRESULT WINAPI DllRegisterServer(void)
{ {
LPWSTR path = NULL;
ITypeLib *tl;
HRESULT hr; HRESULT hr;
TRACE("\n"); TRACE("\n");
@ -659,6 +664,16 @@ HRESULT WINAPI DllRegisterServer(void)
hr = register_interfaces(interface_list); hr = register_interfaces(interface_list);
if (SUCCEEDED(hr)) if (SUCCEEDED(hr))
hr = register_msiexec(); hr = register_msiexec();
tl = get_msi_typelib( &path );
if (tl)
{
hr = RegisterTypeLib( tl, path, NULL );
ITypeLib_Release( tl );
}
else
hr = E_FAIL;
return hr; return hr;
} }