James Hawkins : msi: Add the ability to query a specific context for a product key.
Alexandre Julliard
julliard at winehq.org
Mon Dec 15 08:27:20 CST 2008
Module: wine
Branch: master
Commit: 4a9f6995aa22097feac6a1e13a29fabc3025f1c0
URL: http://source.winehq.org/git/wine.git/?a=commit;h=4a9f6995aa22097feac6a1e13a29fabc3025f1c0
Author: James Hawkins <jhawkins at codeweavers.com>
Date: Sun Dec 14 21:07:06 2008 -0600
msi: Add the ability to query a specific context for a product key.
---
dlls/msi/action.c | 18 ++++--------------
dlls/msi/msi.c | 3 ++-
dlls/msi/msipriv.h | 4 ++--
dlls/msi/registry.c | 17 ++++++++++-------
4 files changed, 18 insertions(+), 24 deletions(-)
diff --git a/dlls/msi/action.c b/dlls/msi/action.c
index 654a7d0..0a23136 100644
--- a/dlls/msi/action.c
+++ b/dlls/msi/action.c
@@ -3589,20 +3589,10 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
if (rc != ERROR_SUCCESS)
goto end;
- if (package->Context == MSIINSTALLCONTEXT_MACHINE)
- {
- rc = MSIREG_OpenUserDataProductKey(package->ProductCode, szLocalSid,
- &hudkey, TRUE);
- if (rc != ERROR_SUCCESS)
- goto end;
- }
- else
- {
- rc = MSIREG_OpenUserDataProductKey(package->ProductCode, NULL,
- &hudkey, TRUE);
- if (rc != ERROR_SUCCESS)
- goto end;
- }
+ rc = MSIREG_OpenUserDataProductKey(package->ProductCode, package->Context,
+ NULL, &hudkey, TRUE);
+ if (rc != ERROR_SUCCESS)
+ goto end;
rc = msi_publish_upgrade_code(package);
if (rc != ERROR_SUCCESS)
diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c
index c49f86d..e6de69d 100644
--- a/dlls/msi/msi.c
+++ b/dlls/msi/msi.c
@@ -1988,7 +1988,8 @@ static INSTALLSTATE MSI_GetComponentPath(LPCWSTR szProduct, LPCWSTR szComponent,
state = INSTALLSTATE_ABSENT;
if ((MSIREG_OpenInstallProps(szProduct, szLocalSid, &hkey, FALSE) == ERROR_SUCCESS ||
- MSIREG_OpenUserDataProductKey(szProduct, NULL, &hkey, FALSE) == ERROR_SUCCESS) &&
+ MSIREG_OpenUserDataProductKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
+ NULL, &hkey, FALSE) == ERROR_SUCCESS) &&
msi_reg_get_val_dword(hkey, wininstaller, &version) &&
GetFileAttributesW(path) != INVALID_FILE_ATTRIBUTES)
{
diff --git a/dlls/msi/msipriv.h b/dlls/msi/msipriv.h
index 99eff8f..0eaa9f3 100644
--- a/dlls/msi/msipriv.h
+++ b/dlls/msi/msipriv.h
@@ -776,8 +776,8 @@ extern UINT MSIREG_OpenUserComponentsKey(LPCWSTR szComponent, HKEY* key, BOOL cr
extern UINT MSIREG_OpenUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid,
HKEY *key, BOOL create);
extern UINT MSIREG_OpenPatchesKey(LPCWSTR szPatch, HKEY* key, BOOL create);
-extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
- HKEY* key, BOOL create);
+extern UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext,
+ LPCWSTR szUserSid, HKEY *key, BOOL create);
extern UINT MSIREG_OpenCurrentUserInstallProps(LPCWSTR szProduct, HKEY* key, BOOL create);
extern UINT MSIREG_OpenInstallProps(LPCWSTR szProduct, LPCWSTR szUserSID,
HKEY *key, BOOL create);
diff --git a/dlls/msi/registry.c b/dlls/msi/registry.c
index db9ec65..a1c3a48 100644
--- a/dlls/msi/registry.c
+++ b/dlls/msi/registry.c
@@ -799,8 +799,8 @@ UINT MSIREG_DeleteUserDataComponentKey(LPCWSTR szComponent, LPCWSTR szUserSid)
return RegDeleteTreeW(HKEY_LOCAL_MACHINE, keypath);
}
-UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
- HKEY *key, BOOL create)
+UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, MSIINSTALLCONTEXT dwContext,
+ LPCWSTR szUserSid, HKEY *key, BOOL create)
{
UINT rc;
WCHAR squished_pc[GUID_SIZE];
@@ -812,7 +812,11 @@ UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
return ERROR_FUNCTION_FAILED;
TRACE("squished (%s)\n", debugstr_w(squished_pc));
- if (!szUserSid)
+ if (dwContext == MSIINSTALLCONTEXT_MACHINE)
+ sprintfW(keypath, szUserDataProd_fmt, szLocalSid, squished_pc);
+ else if (szUserSid)
+ sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc);
+ else
{
rc = get_user_sid(&usersid);
if (rc != ERROR_SUCCESS || !usersid)
@@ -824,8 +828,6 @@ UINT MSIREG_OpenUserDataProductKey(LPCWSTR szProduct, LPCWSTR szUserSid,
sprintfW(keypath, szUserDataProd_fmt, usersid, squished_pc);
LocalFree(usersid);
}
- else
- sprintfW(keypath, szUserDataProd_fmt, szUserSid, squished_pc);
if (create)
rc = RegCreateKeyW(HKEY_LOCAL_MACHINE, keypath, key);
@@ -1679,7 +1681,8 @@ static UINT msi_get_patch_state(LPCWSTR prodcode, LPCWSTR usersid,
*state = MSIPATCHSTATE_INVALID;
/* FIXME: usersid might not be current user */
- r = MSIREG_OpenUserDataProductKey(prodcode, NULL, &prod, FALSE);
+ r = MSIREG_OpenUserDataProductKey(prodcode, MSIINSTALLCONTEXT_USERUNMANAGED,
+ NULL, &prod, FALSE);
if (r != ERROR_SUCCESS)
return ERROR_NO_MORE_ITEMS;
@@ -1826,7 +1829,7 @@ static UINT msi_check_product_patches(LPCWSTR prodcode, LPCWSTR usersid,
{
usersid = szEmpty;
- if (MSIREG_OpenUserDataProductKey(prodcode, szLocalSid, &localprod, FALSE) == ERROR_SUCCESS &&
+ if (MSIREG_OpenUserDataProductKey(prodcode, context, NULL, &localprod, FALSE) == ERROR_SUCCESS &&
RegOpenKeyExW(localprod, szPatches, 0, KEY_READ, &localpatch) == ERROR_SUCCESS &&
RegOpenKeyExW(localpatch, ptr, 0, KEY_READ, &patchkey) == ERROR_SUCCESS)
{
More information about the wine-cvs
mailing list