msi: Add the ability to query a specific context for a product key.

This commit is contained in:
James Hawkins 2008-12-14 21:07:06 -06:00 committed by Alexandre Julliard
parent d195ee3cc4
commit 4a9f6995aa
4 changed files with 18 additions and 24 deletions

View File

@ -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)

View File

@ -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)
{

View File

@ -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);

View File

@ -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)
{