Signed-off-by: Hans Leidekker hans@codeweavers.com --- dlls/msi/action.c | 58 ++++++++++++++++------------------------------- 1 file changed, 20 insertions(+), 38 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c index 5290806d3f..849335edde 100644 --- a/dlls/msi/action.c +++ b/dlls/msi/action.c @@ -3317,66 +3317,48 @@ static LPWSTR resolve_keypath( MSIPACKAGE* package, MSICOMPONENT *cmp ) return NULL; }
-static HKEY openSharedDLLsKey(void) +static HKEY open_shared_dlls_key( MSICOMPONENT *comp, BOOL create, REGSAM access ) { - HKEY hkey=0; static const WCHAR path[] = - {'S','o','f','t','w','a','r','e','\', - 'M','i','c','r','o','s','o','f','t','\', - 'W','i','n','d','o','w','s','\', - 'C','u','r','r','e','n','t','V','e','r','s','i','o','n','\', + {'S','o','f','t','w','a','r','e','\','M','i','c','r','o','s','o','f','t','\', + 'W','i','n','d','o','w','s','\','C','u','r','r','e','n','t','V','e','r','s','i','o','n','\', 'S','h','a','r','e','d','D','L','L','s',0}; - - RegCreateKeyW(HKEY_LOCAL_MACHINE,path,&hkey); - return hkey; + return open_key( comp, HKEY_LOCAL_MACHINE, path, create, access ); }
-static UINT ACTION_GetSharedDLLsCount(LPCWSTR dll) +static UINT get_shared_dlls_count( MSICOMPONENT *comp ) { - HKEY hkey; - DWORD count=0; - DWORD type; - DWORD sz = sizeof(count); - DWORD rc; - - hkey = openSharedDLLsKey(); - rc = RegQueryValueExW(hkey, dll, NULL, &type, (LPBYTE)&count, &sz); - if (rc != ERROR_SUCCESS) - count = 0; - RegCloseKey(hkey); + DWORD count, type, sz = sizeof(count); + HKEY hkey = open_shared_dlls_key( comp, FALSE, KEY_READ ); + if (RegQueryValueExW( hkey, comp->FullKeypath, NULL, &type, (BYTE *)&count, &sz )) count = 0; + RegCloseKey( hkey ); return count; }
-static UINT ACTION_WriteSharedDLLsCount(LPCWSTR path, UINT count) +static void write_shared_dlls_count( MSICOMPONENT *comp, const WCHAR *path, INT count ) { - HKEY hkey; - - hkey = openSharedDLLsKey(); + HKEY hkey = open_shared_dlls_key( comp, TRUE, KEY_SET_VALUE ); if (count > 0) msi_reg_set_val_dword( hkey, path, count ); else - RegDeleteValueW(hkey,path); + RegDeleteValueW( hkey, path ); RegCloseKey(hkey); - return count; }
-static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp ) +static void refcount_component( MSIPACKAGE *package, MSICOMPONENT *comp ) { MSIFEATURE *feature; INT count = 0; BOOL write = FALSE;
/* only refcount DLLs */ - if (comp->KeyPath == NULL || - comp->assembly || - comp->Attributes & msidbComponentAttributesRegistryKeyPath || + if (!comp->KeyPath || comp->assembly || comp->Attributes & msidbComponentAttributesRegistryKeyPath || comp->Attributes & msidbComponentAttributesODBCDataSource) write = FALSE; else { - count = ACTION_GetSharedDLLsCount( comp->FullKeypath); + count = get_shared_dlls_count( comp ); write = (count > 0); - if (comp->Attributes & msidbComponentAttributesSharedDllRefCount) write = TRUE; } @@ -3419,18 +3401,18 @@ static void ACTION_RefCountComponent( MSIPACKAGE* package, MSICOMPONENT *comp ) LIST_FOR_EACH_ENTRY( file, &package->files, MSIFILE, entry ) { if (file->Component == comp) - ACTION_WriteSharedDLLsCount( file->TargetPath, count ); + write_shared_dlls_count( comp, file->TargetPath, count ); } } - + /* add a count for permanent */ if (comp->Attributes & msidbComponentAttributesPermanent) count ++; - + comp->RefCount = count;
if (write) - ACTION_WriteSharedDLLsCount( comp->FullKeypath, comp->RefCount ); + write_shared_dlls_count( comp, comp->FullKeypath, comp->RefCount ); }
static WCHAR *build_full_keypath( MSIPACKAGE *package, MSICOMPONENT *comp ) @@ -3480,7 +3462,7 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package) msi_free( comp->FullKeypath ); comp->FullKeypath = build_full_keypath( package, comp );
- ACTION_RefCountComponent( package, comp ); + refcount_component( package, comp );
if (package->need_rollback) action = comp->Installed; else action = comp->ActionRequest;