msi: Factor out the code to open the UserData features key.
This commit is contained in:
parent
0c01c586c7
commit
e3074348fc
|
@ -3846,20 +3846,10 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
|
|||
if (rc != ERROR_SUCCESS)
|
||||
goto end;
|
||||
|
||||
if (package->Context == MSIINSTALLCONTEXT_MACHINE)
|
||||
{
|
||||
rc = MSIREG_OpenLocalUserDataFeaturesKey(package->ProductCode,
|
||||
&userdata, TRUE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
goto end;
|
||||
}
|
||||
else
|
||||
{
|
||||
rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode,
|
||||
&userdata, TRUE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
goto end;
|
||||
}
|
||||
rc = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, package->Context,
|
||||
&userdata, TRUE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
goto end;
|
||||
|
||||
/* here the guids are base 85 encoded */
|
||||
LIST_FOR_EACH_ENTRY( feature, &package->features, MSIFEATURE, entry )
|
||||
|
@ -3965,7 +3955,8 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
|
|||
RegCloseKey(hkey);
|
||||
}
|
||||
|
||||
r = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, &hkey, FALSE);
|
||||
r = MSIREG_OpenUserDataFeaturesKey(package->ProductCode, package->Context,
|
||||
&hkey, FALSE);
|
||||
if (r == ERROR_SUCCESS)
|
||||
{
|
||||
RegDeleteValueW(hkey, feature->Feature);
|
||||
|
|
|
@ -1958,9 +1958,13 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
|||
return r;
|
||||
|
||||
if (machine)
|
||||
rc = MSIREG_OpenLocalUserDataFeaturesKey(szProduct, &hkey, FALSE);
|
||||
rc = MSIREG_OpenUserDataFeaturesKey(szProduct,
|
||||
MSIINSTALLCONTEXT_MACHINE,
|
||||
&hkey, FALSE);
|
||||
else
|
||||
rc = MSIREG_OpenUserDataFeaturesKey(szProduct, &hkey, FALSE);
|
||||
rc = MSIREG_OpenUserDataFeaturesKey(szProduct,
|
||||
MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||
&hkey, FALSE);
|
||||
|
||||
if (rc != ERROR_SUCCESS)
|
||||
return INSTALLSTATE_ADVERTISED;
|
||||
|
|
|
@ -770,7 +770,8 @@ extern UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
|
|||
HKEY *key, BOOL create);
|
||||
extern UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create);
|
||||
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);
|
||||
|
@ -788,7 +789,6 @@ extern UINT MSIREG_DeleteUserProductKey(LPCWSTR szProduct);
|
|||
extern UINT MSIREG_DeleteUserDataProductKey(LPCWSTR szProduct);
|
||||
extern UINT MSIREG_OpenLocalSystemProductKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
||||
extern UINT MSIREG_OpenLocalSystemComponentKey(LPCWSTR szComponent, 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);
|
||||
|
|
|
@ -684,47 +684,37 @@ UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
|
|||
return rc;
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, HKEY *key, BOOL create)
|
||||
UINT MSIREG_OpenUserDataFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
|
||||
HKEY *key, BOOL create)
|
||||
{
|
||||
UINT rc;
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
WCHAR keypath[0x200];
|
||||
UINT r;
|
||||
LPWSTR usersid;
|
||||
|
||||
TRACE("%s\n", debugstr_w(szProduct));
|
||||
if (!squash_guid(szProduct, squished_pc))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
TRACE("squished (%s)\n", debugstr_w(squished_pc));
|
||||
|
||||
rc = get_user_sid(&usersid);
|
||||
if (rc != ERROR_SUCCESS || !usersid)
|
||||
{
|
||||
ERR("Failed to retrieve user SID: %d\n", rc);
|
||||
return rc;
|
||||
}
|
||||
|
||||
sprintfW(keypath, szUserDataFeatures_fmt, usersid, squished_pc);
|
||||
|
||||
if (create)
|
||||
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
else
|
||||
rc = RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
|
||||
LocalFree(usersid);
|
||||
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));
|
||||
TRACE("(%s, %d, %d)\n", debugstr_w(szProduct), context, create);
|
||||
|
||||
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 (context == MSIINSTALLCONTEXT_MACHINE)
|
||||
{
|
||||
sprintfW(keypath, szUserDataFeatures_fmt, localsid, squished_pc);
|
||||
}
|
||||
else
|
||||
{
|
||||
r = get_user_sid(&usersid);
|
||||
if (r != ERROR_SUCCESS || !usersid)
|
||||
{
|
||||
ERR("Failed to retrieve user SID: %d\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
sprintfW(keypath, szUserDataFeatures_fmt, usersid, squished_pc);
|
||||
LocalFree(usersid);
|
||||
}
|
||||
|
||||
if (create)
|
||||
return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
|
|
Loading…
Reference in New Issue