{
MSIFEATURE *feature;
UINT rc;
- HKEY hukey=0;
- HKEY userdata=0;
+ HKEY hkey;
+ HKEY userdata;
if (!msi_check_publish(package))
return ERROR_SUCCESS;
- rc = MSIREG_OpenUserFeaturesKey(package->ProductCode,&hukey,TRUE);
- if (rc != ERROR_SUCCESS)
- goto end;
+ if (package->Context == MSIINSTALLCONTEXT_MACHINE)
+ {
+ rc = MSIREG_OpenLocalClassesFeaturesKey(package->ProductCode,
+ &hkey, TRUE);
+ if (rc != ERROR_SUCCESS)
+ goto end;
- rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, &userdata, TRUE);
- if (rc != ERROR_SUCCESS)
- goto end;
+ rc = MSIREG_OpenLocalUserDataFeaturesKey(package->ProductCode,
+ &userdata, TRUE);
+ if (rc != ERROR_SUCCESS)
+ goto end;
+ }
+ else
+ {
+ rc = MSIREG_OpenUserFeaturesKey(package->ProductCode, &hkey, TRUE);
+ if (rc != ERROR_SUCCESS)
+ goto end;
+
+ rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode,
+ &userdata, TRUE);
+ if (rc != ERROR_SUCCESS)
+ goto end;
+ }
/* here the guids are base 85 encoded */
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
{
static const WCHAR emptyW[] = {0};
size += sizeof(WCHAR);
- RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
+ RegSetValueExW(hkey,feature->Feature,0,REG_SZ,
(LPBYTE)(feature->Feature_Parent ? feature->Feature_Parent : emptyW),size);
}
else
data[1] = 0;
if (feature->Feature_Parent)
strcpyW( &data[1], feature->Feature_Parent );
- RegSetValueExW(hukey,feature->Feature,0,REG_SZ,
+ RegSetValueExW(hkey,feature->Feature,0,REG_SZ,
(LPBYTE)data,size);
msi_free(data);
}
}
end:
- RegCloseKey(hukey);
+ RegCloseKey(hkey);
+ RegCloseKey(userdata);
return rc;
}
extern UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, HKEY *key, BOOL create);
extern UINT MSIREG_OpenLocalClassesProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
+extern UINT MSIREG_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
extern UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
+extern UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
extern UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct);
extern UINT MSIREG_DeleteLocalUserDataComponentKey(LPCWSTR szComponent);
extern UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent);
'I','n','s','t','a','l','l','e','r','\\',
'P','r','o','d','u','c','t','s','\\','%','s',0};
+static const WCHAR szInstaller_LocalClassesFeat_fmt[] = {
+'S','o','f','t','w','a','r','e','\\',
+'C','l','a','s','s','e','s','\\',
+'I','n','s','t','a','l','l','e','r','\\',
+'F','e','a','t','u','r','e','s','\\','%','s',0};
+
static const WCHAR szInstaller_LocalManagedProd_fmt[] = {
'S','o','f','t','w','a','r','e','\\',
'M','i','c','r','o','s','o','f','t','\\',
return rc;
}
+UINT MSIREG_OpenLocalUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
+{
+ WCHAR squished_pc[GUID_SIZE];
+ WCHAR keypath[0x200];
+
+ TRACE("%s\n", debugstr_w(szProduct));
+ if (!squash_guid(szProduct, squished_pc))
+ return ERROR_FUNCTION_FAILED;
+ TRACE("squished (%s)\n", debugstr_w(squished_pc));
+
+ sprintfW(keypath, szUserDataFeatures_fmt, localsid, squished_pc);
+
+ if (create)
+ return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
+
+ return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
+}
+
UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create)
{
UINT rc;
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
}
+UINT MSIREG_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
+{
+ WCHAR squished_pc[GUID_SIZE];
+ WCHAR keypath[0x200];
+
+ TRACE("%s\n", debugstr_w(szProductCode));
+
+ if (!squash_guid(szProductCode, squished_pc))
+ return ERROR_FUNCTION_FAILED;
+
+ TRACE("squished (%s)\n", debugstr_w(squished_pc));
+
+ sprintfW(keypath, szInstaller_LocalClassesFeat_fmt, squished_pc);
+
+ if (create)
+ return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
+
+ return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
+}
+
UINT MSIREG_OpenLocalManagedProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
{
WCHAR squished_pc[GUID_SIZE];
"\\84A88FD7F6998CE40A22FB59F6B9C2BB\\Features";
static const CHAR featkey[] = "Software\\Microsoft\\Windows\\CurrentVersion"
"\\Installer\\Features";
+ static const CHAR classfeat[] = "Software\\Classes\\Installer\\Features"
+ "\\84A88FD7F6998CE40A22FB59F6B9C2BB";
get_user_sid(&usersid);
if (!usersid)
res = RegOpenKeyA(HKEY_LOCAL_MACHINE, featkey, &hkey);
ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
+ res = RegOpenKeyA(HKEY_LOCAL_MACHINE, classfeat, &hkey);
+ ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
+
res = RegOpenKeyA(HKEY_CURRENT_USER, cupath, &hkey);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
RegDeleteKeyA(hkey, "");
RegCloseKey(hkey);
+ /* PublishFeatures, machine */
+ r = MsiInstallProductA(msifile, "PUBLISH_FEATURES=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");
+
+ res = RegOpenKeyA(HKEY_LOCAL_MACHINE, featkey, &hkey);
+ ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
+
+ res = RegOpenKeyA(HKEY_CURRENT_USER, cupath, &hkey);
+ ok(res == ERROR_FILE_NOT_FOUND, "Expected ERROR_FILE_NOT_FOUND, got %d\n", res);
+
+ res = RegOpenKeyA(HKEY_LOCAL_MACHINE, classfeat, &hkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ CHECK_REG_STR(hkey, "feature", "");
+ CHECK_REG_STR(hkey, "montecristo", "");
+
+ RegDeleteValueA(hkey, "feature");
+ RegDeleteValueA(hkey, "montecristo");
+ RegDeleteKeyA(hkey, "");
+ RegCloseKey(hkey);
+
+ sprintf(keypath, udpath, "S-1-5-18");
+ res = RegOpenKeyA(HKEY_LOCAL_MACHINE, keypath, &hkey);
+ ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
+
+ CHECK_REG_STR(hkey, "feature", "VGtfp^p+,?82@JU1j_KE");
+ CHECK_REG_STR(hkey, "montecristo", "VGtfp^p+,?82@JU1j_KE");
+
+ RegDeleteValueA(hkey, "feature");
+ RegDeleteValueA(hkey, "montecristo");
+ RegDeleteKeyA(hkey, "");
+ RegCloseKey(hkey);
+
DeleteFile(msifile);
DeleteFile("msitest\\maximus");
RemoveDirectory("msitest");