msi: Set the install context based on the ALLUSERS property.

This commit is contained in:
James Hawkins 2008-04-05 00:10:02 -05:00 committed by Alexandre Julliard
parent 30c1b88828
commit 82517d6d67
4 changed files with 51 additions and 17 deletions

View File

@ -3345,13 +3345,22 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
/* ok there is a lot more done here but i need to figure out what */ /* ok there is a lot more done here but i need to figure out what */
rc = MSIREG_OpenProductsKey(package->ProductCode,&hkey,TRUE); if (package->Context == MSIINSTALLCONTEXT_MACHINE)
if (rc != ERROR_SUCCESS) {
goto end; rc = MSIREG_OpenLocalClassesProductKey(package->ProductCode, &hukey, TRUE);
if (rc != ERROR_SUCCESS)
goto end;
}
else
{
rc = MSIREG_OpenProductsKey(package->ProductCode,&hkey,TRUE);
if (rc != ERROR_SUCCESS)
goto end;
rc = MSIREG_OpenUserProductsKey(package->ProductCode,&hukey,TRUE); rc = MSIREG_OpenUserProductsKey(package->ProductCode,&hukey,TRUE);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto end; goto end;
}
rc = RegCreateKeyW(hukey, szSourceList, &source); rc = RegCreateKeyW(hukey, szSourceList, &source);
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
@ -3400,19 +3409,19 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
buffer = strrchrW( package->PackagePath, '\\') + 1; buffer = strrchrW( package->PackagePath, '\\') + 1;
rc = MsiSourceListSetInfoW( package->ProductCode, NULL, rc = MsiSourceListSetInfoW( package->ProductCode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, package->Context, MSICODE_PRODUCT,
INSTALLPROPERTY_PACKAGENAMEW, buffer ); INSTALLPROPERTY_PACKAGENAMEW, buffer );
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto end; goto end;
rc = MsiSourceListSetInfoW( package->ProductCode, NULL, rc = MsiSourceListSetInfoW( package->ProductCode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, package->Context, MSICODE_PRODUCT,
INSTALLPROPERTY_MEDIAPACKAGEPATHW, szEmpty ); INSTALLPROPERTY_MEDIAPACKAGEPATHW, szEmpty );
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto end; goto end;
rc = MsiSourceListSetInfoW( package->ProductCode, NULL, rc = MsiSourceListSetInfoW( package->ProductCode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, package->Context, MSICODE_PRODUCT,
INSTALLPROPERTY_DISKPROMPTW, szEmpty ); INSTALLPROPERTY_DISKPROMPTW, szEmpty );
if (rc != ERROR_SUCCESS) if (rc != ERROR_SUCCESS)
goto end; goto end;
@ -4221,13 +4230,13 @@ static UINT ACTION_ResolveSource(MSIPACKAGE* package)
DWORD size = 0; DWORD size = 0;
rc = MsiSourceListGetInfoW(package->ProductCode, NULL, rc = MsiSourceListGetInfoW(package->ProductCode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, package->Context, MSICODE_PRODUCT,
INSTALLPROPERTY_DISKPROMPTW,NULL,&size); INSTALLPROPERTY_DISKPROMPTW,NULL,&size);
if (rc == ERROR_MORE_DATA) if (rc == ERROR_MORE_DATA)
{ {
prompt = msi_alloc(size * sizeof(WCHAR)); prompt = msi_alloc(size * sizeof(WCHAR));
MsiSourceListGetInfoW(package->ProductCode, NULL, MsiSourceListGetInfoW(package->ProductCode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, package->Context, MSICODE_PRODUCT,
INSTALLPROPERTY_DISKPROMPTW,prompt,&size); INSTALLPROPERTY_DISKPROMPTW,prompt,&size);
} }
else else

View File

@ -581,11 +581,11 @@ static UINT load_media_info(MSIPACKAGE *package, MSIFILE *file, struct media_inf
} }
if (mi->type == DRIVE_CDROM || mi->type == DRIVE_REMOVABLE) if (mi->type == DRIVE_CDROM || mi->type == DRIVE_REMOVABLE)
msi_package_add_media_disk(package, MSIINSTALLCONTEXT_USERUNMANAGED, msi_package_add_media_disk(package, package->Context,
MSICODE_PRODUCT, mi->disk_id, MSICODE_PRODUCT, mi->disk_id,
mi->volume_label, mi->disk_prompt); mi->volume_label, mi->disk_prompt);
msi_package_add_info(package, MSIINSTALLCONTEXT_USERUNMANAGED, msi_package_add_info(package, package->Context,
options, INSTALLPROPERTY_LASTUSEDSOURCEW, source); options, INSTALLPROPERTY_LASTUSEDSOURCEW, source);
msi_free(source_dir); msi_free(source_dir);
@ -603,7 +603,7 @@ static UINT find_published_source(MSIPACKAGE *package, struct media_info *mi)
UINT r; UINT r;
r = MsiSourceListGetInfoW(package->ProductCode, NULL, r = MsiSourceListGetInfoW(package->ProductCode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, MSICODE_PRODUCT, package->Context, MSICODE_PRODUCT,
INSTALLPROPERTY_LASTUSEDSOURCEW, source, &size); INSTALLPROPERTY_LASTUSEDSOURCEW, source, &size);
if (r != ERROR_SUCCESS) if (r != ERROR_SUCCESS)
return r; return r;
@ -612,7 +612,7 @@ static UINT find_published_source(MSIPACKAGE *package, struct media_info *mi)
volumesz = MAX_PATH; volumesz = MAX_PATH;
promptsz = MAX_PATH; promptsz = MAX_PATH;
while (MsiSourceListEnumMediaDisksW(package->ProductCode, NULL, while (MsiSourceListEnumMediaDisksW(package->ProductCode, NULL,
MSIINSTALLCONTEXT_USERUNMANAGED, package->Context,
MSICODE_PRODUCT, index++, &id, MSICODE_PRODUCT, index++, &id,
volume, &volumesz, prompt, &promptsz) == ERROR_SUCCESS) volume, &volumesz, prompt, &promptsz) == ERROR_SUCCESS)
{ {

View File

@ -307,6 +307,7 @@ typedef struct tagMSIPACKAGE
float center_y; float center_y;
UINT WordCount; UINT WordCount;
UINT Context;
struct list subscriptions; struct list subscriptions;

View File

@ -416,7 +416,6 @@ static VOID set_installer_properties(MSIPACKAGE *package)
static const WCHAR szColorBits[] = {'C','o','l','o','r','B','i','t','s',0}; static const WCHAR szColorBits[] = {'C','o','l','o','r','B','i','t','s',0};
static const WCHAR szIntFormat[] = {'%','d',0}; static const WCHAR szIntFormat[] = {'%','d',0};
static const WCHAR szIntel[] = { 'I','n','t','e','l',0 }; static const WCHAR szIntel[] = { 'I','n','t','e','l',0 };
static const WCHAR szAllUsers[] = { 'A','L','L','U','S','E','R','S',0 };
static const WCHAR szUserInfo[] = { static const WCHAR szUserInfo[] = {
'S','O','F','T','W','A','R','E','\\', 'S','O','F','T','W','A','R','E','\\',
'M','i','c','r','o','s','o','f','t','\\', 'M','i','c','r','o','s','o','f','t','\\',
@ -542,7 +541,6 @@ static VOID set_installer_properties(MSIPACKAGE *package)
/* in a wine environment the user is always admin and privileged */ /* in a wine environment the user is always admin and privileged */
MSI_SetPropertyW(package,szAdminUser,szOne); MSI_SetPropertyW(package,szAdminUser,szOne);
MSI_SetPropertyW(package,szPriv,szOne); MSI_SetPropertyW(package,szPriv,szOne);
MSI_SetPropertyW(package, szAllUsers, szOne);
/* set the os things */ /* set the os things */
OSVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW); OSVersion.dwOSVersionInfoSize = sizeof(OSVERSIONINFOEXW);
@ -762,6 +760,30 @@ static UINT msi_load_admin_properties(MSIPACKAGE *package)
return r; return r;
} }
static UINT msi_set_context(MSIPACKAGE *package)
{
WCHAR val[10];
DWORD sz = 10;
DWORD num;
UINT r;
static const WCHAR szOne[] = {'1',0};
static const WCHAR szAllUsers[] = {'A','L','L','U','S','E','R','S',0};
package->Context = MSIINSTALLCONTEXT_USERUNMANAGED;
r = MSI_GetPropertyW(package, szAllUsers, val, &sz);
if (r == ERROR_SUCCESS)
{
num = atolW(val);
if (num == 1 || num == 2)
package->Context = MSIINSTALLCONTEXT_MACHINE;
}
MSI_SetPropertyW(package, szAllUsers, szOne);
return ERROR_SUCCESS;
}
MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url ) MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
{ {
static const WCHAR szLevel[] = { 'U','I','L','e','v','e','l',0 }; static const WCHAR szLevel[] = { 'U','I','L','e','v','e','l',0 };
@ -801,6 +823,8 @@ MSIPACKAGE *MSI_CreatePackage( MSIDATABASE *db, LPCWSTR base_url )
if (package->WordCount & MSIWORDCOUNT_ADMINISTRATIVE) if (package->WordCount & MSIWORDCOUNT_ADMINISTRATIVE)
msi_load_admin_properties( package ); msi_load_admin_properties( package );
msi_set_context( package );
} }
return package; return package;