msi: Factor out the code to open the features key.
This commit is contained in:
parent
70be1e7746
commit
0c01c586c7
|
@ -3841,13 +3841,13 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
|
|||
if (!msi_check_publish(package))
|
||||
return ERROR_SUCCESS;
|
||||
|
||||
rc = MSIREG_OpenFeaturesKey(package->ProductCode, package->Context,
|
||||
&hkey, 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_OpenLocalUserDataFeaturesKey(package->ProductCode,
|
||||
&userdata, TRUE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
|
@ -3855,10 +3855,6 @@ static UINT ACTION_PublishFeatures(MSIPACKAGE *package)
|
|||
}
|
||||
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)
|
||||
|
@ -3961,7 +3957,8 @@ static UINT msi_unpublish_feature(MSIPACKAGE *package, MSIFEATURE *feature)
|
|||
|
||||
TRACE("unpublishing feature %s\n", debugstr_w(feature->Feature));
|
||||
|
||||
r = MSIREG_OpenUserFeaturesKey(package->ProductCode, &hkey, FALSE);
|
||||
r = MSIREG_OpenFeaturesKey(package->ProductCode, package->Context,
|
||||
&hkey, FALSE);
|
||||
if (r == ERROR_SUCCESS)
|
||||
{
|
||||
RegDeleteValueW(hkey, feature->Feature);
|
||||
|
|
|
@ -1933,10 +1933,13 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
|
|||
if (!squash_guid( szProduct, squishProduct ))
|
||||
return INSTALLSTATE_INVALIDARG;
|
||||
|
||||
if (MSIREG_OpenManagedFeaturesKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS &&
|
||||
MSIREG_OpenUserFeaturesKey(szProduct, &hkey, FALSE) != ERROR_SUCCESS)
|
||||
if (MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
|
||||
&hkey, FALSE) != ERROR_SUCCESS &&
|
||||
MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
|
||||
&hkey, FALSE) != ERROR_SUCCESS)
|
||||
{
|
||||
rc = MSIREG_OpenLocalClassesFeaturesKey(szProduct, &hkey, FALSE);
|
||||
rc = MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_MACHINE,
|
||||
&hkey, FALSE);
|
||||
if (rc != ERROR_SUCCESS)
|
||||
return INSTALLSTATE_UNKNOWN;
|
||||
|
||||
|
|
|
@ -766,8 +766,10 @@ extern UINT MSIREG_OpenUninstallKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
|||
extern UINT MSIREG_DeleteUninstallKey(LPCWSTR szProduct);
|
||||
extern UINT MSIREG_OpenProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
|
||||
HKEY* key, BOOL create);
|
||||
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_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenInstallerFeaturesKey(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);
|
||||
|
@ -778,7 +780,6 @@ extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL cre
|
|||
extern UINT MSIREG_OpenLocalUserDataProductKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenLocalSystemInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
extern UINT MSIREG_OpenUserUpgradeCodesKey(LPCWSTR szProduct, HKEY* key, BOOL create);
|
||||
|
@ -787,8 +788,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_OpenLocalClassesFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create);
|
||||
extern UINT MSIREG_OpenManagedFeaturesKey(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);
|
||||
|
|
|
@ -605,25 +605,48 @@ UINT MSIREG_OpenUserPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create)
|
|||
return rc;
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenUserFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
|
||||
UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, MSIINSTALLCONTEXT context,
|
||||
HKEY *key, BOOL create)
|
||||
{
|
||||
UINT rc;
|
||||
UINT r;
|
||||
LPWSTR usersid;
|
||||
HKEY root = HKEY_LOCAL_MACHINE;
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
WCHAR keypath[0x200];
|
||||
WCHAR keypath[MAX_PATH];
|
||||
|
||||
TRACE("%s\n",debugstr_w(szProduct));
|
||||
if (!squash_guid(szProduct,squished_pc))
|
||||
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,szUserFeatures_fmt,squished_pc);
|
||||
if (context == MSIINSTALLCONTEXT_MACHINE)
|
||||
{
|
||||
sprintfW(keypath, szInstaller_LocalClassesFeat_fmt, squished_pc);
|
||||
}
|
||||
else if (context == MSIINSTALLCONTEXT_USERUNMANAGED)
|
||||
{
|
||||
root = HKEY_CURRENT_USER;
|
||||
sprintfW(keypath, szUserFeatures_fmt, 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, szInstaller_LocalManagedFeat_fmt, usersid, squished_pc);
|
||||
LocalFree(usersid);
|
||||
}
|
||||
|
||||
if (create)
|
||||
rc = RegCreateKeyW(HKEY_CURRENT_USER,keypath,key);
|
||||
else
|
||||
rc = RegOpenKeyW(HKEY_CURRENT_USER,keypath,key);
|
||||
return RegCreateKeyW(root, keypath, key);
|
||||
|
||||
return rc;
|
||||
return RegOpenKeyW(root, keypath, key);
|
||||
}
|
||||
|
||||
UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct)
|
||||
|
@ -640,7 +663,7 @@ UINT MSIREG_DeleteUserFeaturesKey(LPCWSTR szProduct)
|
|||
return RegDeleteTreeW(HKEY_CURRENT_USER, keypath);
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
|
||||
UINT MSIREG_OpenInstallerFeaturesKey(LPCWSTR szProduct, HKEY* key, BOOL create)
|
||||
{
|
||||
UINT rc;
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
|
@ -1108,26 +1131,6 @@ UINT MSIREG_DeleteLocalClassesProductKey(LPCWSTR szProductCode)
|
|||
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
|
||||
}
|
||||
|
||||
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_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode)
|
||||
{
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
|
@ -1145,36 +1148,6 @@ UINT MSIREG_DeleteLocalClassesFeaturesKey(LPCWSTR szProductCode)
|
|||
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenManagedFeaturesKey(LPCWSTR szProductCode, HKEY *key, BOOL create)
|
||||
{
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
WCHAR keypath[0x200];
|
||||
LPWSTR usersid;
|
||||
UINT r;
|
||||
|
||||
TRACE("%s\n", debugstr_w(szProductCode));
|
||||
|
||||
if (!squash_guid(szProductCode, squished_pc))
|
||||
return ERROR_FUNCTION_FAILED;
|
||||
|
||||
TRACE("squished (%s)\n", debugstr_w(squished_pc));
|
||||
|
||||
r = get_user_sid(&usersid);
|
||||
if (r != ERROR_SUCCESS || !usersid)
|
||||
{
|
||||
ERR("Failed to retrieve user SID: %d\n", r);
|
||||
return r;
|
||||
}
|
||||
|
||||
sprintfW(keypath, szInstaller_LocalManagedFeat_fmt, usersid, squished_pc);
|
||||
LocalFree(usersid);
|
||||
|
||||
if (create)
|
||||
return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
|
||||
return RegOpenKeyW(HKEY_LOCAL_MACHINE, keypath, key);
|
||||
}
|
||||
|
||||
UINT MSIREG_OpenClassesUpgradeCodesKey(LPCWSTR szUpgradeCode, HKEY* key, BOOL create)
|
||||
{
|
||||
WCHAR squished_pc[GUID_SIZE];
|
||||
|
@ -1381,7 +1354,7 @@ UINT WINAPI MsiEnumFeaturesW(LPCWSTR szProduct, DWORD index,
|
|||
if( !szProduct )
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
r = MSIREG_OpenFeaturesKey(szProduct,&hkeyProduct,FALSE);
|
||||
r = MSIREG_OpenInstallerFeaturesKey(szProduct,&hkeyProduct,FALSE);
|
||||
if( r != ERROR_SUCCESS )
|
||||
return ERROR_NO_MORE_ITEMS;
|
||||
|
||||
|
|
Loading…
Reference in New Issue