msi: Add the ability to open multiple users' component keys.

This commit is contained in:
James Hawkins 2008-12-09 00:21:00 -06:00 committed by Alexandre Julliard
parent 930b429d1e
commit b198f4f23f
4 changed files with 27 additions and 37 deletions

View File

@ -2859,9 +2859,11 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
continue;
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
rc = MSIREG_OpenLocalUserDataComponentKey(comp->ComponentId, &hkey, TRUE);
rc = MSIREG_OpenUserDataComponentKey(comp->ComponentId, szLocalSid,
&hkey, TRUE);
else
rc = MSIREG_OpenUserDataComponentKey(comp->ComponentId, &hkey, TRUE);
rc = MSIREG_OpenUserDataComponentKey(comp->ComponentId, NULL,
&hkey, TRUE);
if (rc != ERROR_SUCCESS)
continue;

View File

@ -618,7 +618,7 @@ UINT WINAPI MsiGetProductCodeW(LPCWSTR szComponent, LPWSTR szBuffer)
if (!squash_guid(szComponent, squished_comp))
return ERROR_INVALID_PARAMETER;
if (MSIREG_OpenUserDataComponentKey(szComponent, &compkey, FALSE) != ERROR_SUCCESS &&
if (MSIREG_OpenUserDataComponentKey(szComponent, NULL, &compkey, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenLocalSystemComponentKey(szComponent, &compkey, FALSE) != ERROR_SUCCESS)
{
return ERROR_UNKNOWN_COMPONENT;
@ -1326,7 +1326,7 @@ static BOOL msi_comp_find_prodcode(LPWSTR squished_pc,
if (context == MSIINSTALLCONTEXT_MACHINE)
r = MSIREG_OpenLocalSystemComponentKey(comp, &hkey, FALSE);
else
r = MSIREG_OpenUserDataComponentKey(comp, &hkey, FALSE);
r = MSIREG_OpenUserDataComponentKey(comp, NULL, &hkey, FALSE);
if (r != ERROR_SUCCESS)
return FALSE;
@ -1777,7 +1777,7 @@ static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
state = INSTALLSTATE_UNKNOWN;
if (MSIREG_OpenLocalSystemComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenUserDataComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS)
MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkey, FALSE) == ERROR_SUCCESS)
{
path = msi_reg_get_val_str(hkey, squished_pc);
RegCloseKey(hkey);
@ -1803,7 +1803,7 @@ static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
RegCloseKey(hkey);
if (MSIREG_OpenLocalSystemComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS ||
MSIREG_OpenUserDataComponentKey(szComponent, &hkey, FALSE) == ERROR_SUCCESS)
MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkey, FALSE) == ERROR_SUCCESS)
{
msi_free(path);
path = msi_reg_get_val_str(hkey, squished_pc);
@ -1991,9 +1991,9 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
StringFromGUID2(&guid, comp, GUID_SIZE);
if (machine)
rc = MSIREG_OpenLocalUserDataComponentKey(comp, &hkey, FALSE);
rc = MSIREG_OpenUserDataComponentKey(comp, szLocalSid, &hkey, FALSE);
else
rc = MSIREG_OpenUserDataComponentKey(comp, &hkey, FALSE);
rc = MSIREG_OpenUserDataComponentKey(comp, NULL, &hkey, FALSE);
if (rc != ERROR_SUCCESS)
{

View File

@ -773,8 +773,8 @@ extern UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL c
UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
HKEY *key, BOOL create);
extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
extern UINT MSIREG_OpenLocalUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid,
HKEY *key, BOOL create);
extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
HKEY* key, BOOL create);

View File

@ -753,24 +753,6 @@ UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create)
return rc;
}
UINT MSIREG_OpenLocalUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create)
{
WCHAR comp[GUID_SIZE];
WCHAR keypath[0x200];
TRACE("%s\n", debugstr_w(szComponent));
if (!squash_guid(szComponent, comp))
return ERROR_FUNCTION_FAILED;
TRACE("squished (%s)\n", debugstr_w(comp));
sprintfW(keypath, szUserDataComp_fmt, szLocalSid, comp);
if (create)
return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
}
UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent)
{
WCHAR comp[GUID_SIZE];
@ -785,7 +767,8 @@ UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent)
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
}
UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create)
UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid,
HKEY *key, BOOL create)
{
UINT rc;
WCHAR comp[GUID_SIZE];
@ -797,6 +780,8 @@ UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create
return ERROR_FUNCTION_FAILED;
TRACE("squished (%s)\n", debugstr_w(comp));
if (!szUserSid)
{
rc = get_user_sid(&usersid);
if (rc != ERROR_SUCCESS || !usersid)
{
@ -805,13 +790,16 @@ UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create
}
sprintfW(keypath, szUserDataComp_fmt, usersid, comp);
LocalFree(usersid);
}
else
sprintfW(keypath, szUserDataComp_fmt, szUserSid, comp);
if (create)
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
else
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
LocalFree(usersid);
return rc;
}
@ -1433,7 +1421,7 @@ UINT WINAPI MsiEnumClientsW(LPCWSTR szComponent, DWORD index, LPWSTR szProduct)
if (!szComponent || !*szComponent || !szProduct)
return ERROR_INVALID_PARAMETER;
if (MSIREG_OpenUserDataComponentKey(szComponent, &hkeyComp, FALSE) != ERROR_SUCCESS &&
if (MSIREG_OpenUserDataComponentKey(szComponent, NULL, &hkeyComp, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenLocalSystemComponentKey(szComponent, &hkeyComp, FALSE) != ERROR_SUCCESS)
return ERROR_UNKNOWN_COMPONENT;