James Hawkins : msi: Factor out the code to open the UserData features key.
Alexandre Julliard
julliard at winehq.org
Tue Nov 4 07:29:09 CST 2008
Module: wine
Branch: master
Commit: e3074348fc5768124304b329a24382d0ee63e0dc
URL: http://source.winehq.org/git/wine.git/?a=commit;h=e3074348fc5768124304b329a24382d0ee63e0dc
Author: James Hawkins <jhawkins at codeweavers.com>
Date: Mon Nov 3 22:16:54 2008 -0600
msi: Factor out the code to open the UserData features key.
---
dlls/msi/action.c | 21 ++++++---------------
dlls/msi/msi.c | 8 ++++++--
dlls/msi/msipriv.h | 4 ++--
dlls/msi/registry.c | 48 +++++++++++++++++++-----------------------------
4 files changed, 33 insertions(+), 48 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 55e8fd2..5d9ba65 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -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);
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index 91792d4..2b3b635 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -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;
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index b853915..d83fae5 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -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);
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index f1059f7..3ed08f7 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -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;
+ UINT r;
+ LPWSTR usersid;
WCHAR squished_pc[GUID_SIZE];
WCHAR keypath[0x200];
- LPWSTR usersid;
- 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));
- rc = get_user_sid(&usersid);
- if (rc != ERROR_SUCCESS || !usersid)
+ if (context == MSIINSTALLCONTEXT_MACHINE)
{
- ERR("Failed to retrieve user SID: %d\n", rc);
- return rc;
+ sprintfW(keypath, szUserDataFeatures_fmt, localsid, squished_pc);
}
-
- 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));
- if (!squash_guid(szProduct, 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, szUserDataFeatures_fmt, localsid, squished_pc);
+ sprintfW(keypath, szUserDataFeatures_fmt, usersid, squished_pc);
+ LocalFree(usersid);
+ }
if (create)
return RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
More information about the wine-cvs
mailing list