msi: Fix the ProcessComponents action to handle the package context.

This commit is contained in:
James Hawkins 2008-06-18 00:51:13 -05:00 committed by Alexandre Julliard
parent 5f11262da9
commit 288af81a7c
4 changed files with 72 additions and 4 deletions

View File

@ -2886,7 +2886,11 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
if (!comp->FullKeypath)
continue;
rc = MSIREG_OpenUserDataComponentKey(comp->ComponentId, &hkey, TRUE);
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
rc = MSIREG_OpenLocalUserDataComponentKey(comp->ComponentId, &hkey, TRUE);
else
rc = MSIREG_OpenUserDataComponentKey(comp->ComponentId, &hkey, TRUE);
if (rc != ERROR_SUCCESS)
continue;
@ -2904,7 +2908,12 @@ static UINT ACTION_ProcessComponents(MSIPACKAGE *package)
RegCloseKey(hkey);
}
else if (ACTION_VerifyComponentForAction(comp, INSTALLSTATE_ABSENT))
MSIREG_DeleteUserDataComponentKey(comp->ComponentId);
{
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
MSIREG_DeleteLocalUserDataComponentKey(comp->ComponentId);
else
MSIREG_DeleteUserDataComponentKey(comp->ComponentId);
}
/* UI stuff */
uirow = MSI_CreateRecord(3);

View File

@ -768,6 +768,7 @@ extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, 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_OpenProductsKey(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
@ -786,6 +787,7 @@ extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, B
extern UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
extern UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
extern UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent);
extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent);
extern LPWSTR msi_reg_get_val_str( HKEY hkey, LPCWSTR name );

View File

@ -214,6 +214,8 @@ static const WCHAR szInstaller_LocalManagedProd_fmt[] = {
'I','n','s','t','a','l','l','e','r','\\',
'P','r','o','d','u','c','t','s','\\','%','s',0};
static const WCHAR localsid[] = {'S','-','1','-','5','-','1','8',0};
BOOL unsquash_guid(LPCWSTR in, LPWSTR out)
{
DWORD i,n=0;
@ -666,6 +668,38 @@ 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, localsid, 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];
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, localsid, comp);
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
}
UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create)
{
UINT rc;
@ -795,8 +829,6 @@ UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY *key,
UINT MSIREG_OpenLocalSystemInstallProps(LPCWSTR szProduct, HKEY *key,
BOOL create)
{
static const WCHAR localsid[] = {'S','-','1','-','5','-','1','8',0};
return MSIREG_OpenInstallProps(szProduct, localsid, key, create);
}

View File

@ -2773,6 +2773,31 @@ static void test_publish_processcomponents(void)
RegDeleteKeyA(comp, "");
RegCloseKey(comp);
/* ProcessComponents, machine */
r = MsiInstallProductA(msifile, "PROCESS_COMPONENTS=1 ALLUSERS=1");
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(delete_pf("msitest\\maximus", TRUE), "File not installed\n");
ok(delete_pf("msitest", FALSE), "File not installed\n");
sprintf(keypath, keyfmt, "S-1-5-18");
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &comp);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
size = MAX_PATH;
res = RegQueryValueExA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB",
NULL, NULL, (LPBYTE)val, &size);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
ok(!lstrcmpA(val, "C:\\Program Files\\msitest\\maximus"),
"Expected \"%s\", got \"%s\"\n", "C:\\Program Files\\msitest\\maximus", val);
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, compkey, &hkey);
ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
RegDeleteValueA(comp, "84A88FD7F6998CE40A22FB59F6B9C2BB");
RegDeleteKeyA(comp, "");
RegCloseKey(comp);
DeleteFile(msifile);
DeleteFile("msitest\\maximus");
RemoveDirectory("msitest");