msi: Allow setting a media disk as the last used source in the internal msi_set_last_used_source.
This commit is contained in:
parent
7d10d1d2d0
commit
cf84e2df5b
|
@ -3508,9 +3508,13 @@ static UINT ACTION_PublishProduct(MSIPACKAGE *package)
|
|||
/* publish the SourceList info */
|
||||
LIST_FOR_EACH_ENTRY(info, &package->sourcelist_info, MSISOURCELISTINFO, entry)
|
||||
{
|
||||
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
||||
info->context, info->options,
|
||||
info->property, info->value);
|
||||
if (!lstrcmpW(info->property, INSTALLPROPERTY_LASTUSEDSOURCEW))
|
||||
msi_set_last_used_source(package->ProductCode, NULL, info->context,
|
||||
info->options, info->value);
|
||||
else
|
||||
MsiSourceListSetInfoW(package->ProductCode, NULL,
|
||||
info->context, info->options,
|
||||
info->property, info->value);
|
||||
}
|
||||
|
||||
LIST_FOR_EACH_ENTRY(disk, &package->sourcelist_media, MSIMEDIADISK, entry)
|
||||
|
|
|
@ -885,6 +885,8 @@ extern BOOL check_unique_action(const MSIPACKAGE *, LPCWSTR);
|
|||
extern WCHAR* generate_error_string(MSIPACKAGE *, UINT, DWORD, ... );
|
||||
extern UINT msi_create_component_directories( MSIPACKAGE *package );
|
||||
extern void msi_ui_error( DWORD msg_id, DWORD type );
|
||||
extern UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
|
||||
MSIINSTALLCONTEXT context, DWORD options, LPCWSTR value);
|
||||
|
||||
/* control event stuff */
|
||||
extern VOID ControlEvent_FireSubscribedEvent(MSIPACKAGE *package, LPCWSTR event,
|
||||
|
|
|
@ -701,15 +701,16 @@ UINT WINAPI MsiSourceListSetInfoA(LPCSTR szProduct, LPCSTR szUserSid,
|
|||
return ret;
|
||||
}
|
||||
|
||||
static UINT set_last_used_source(HKEY source, LPCWSTR product, LPCWSTR usersid,
|
||||
MSIINSTALLCONTEXT context, DWORD options,
|
||||
LPCWSTR value)
|
||||
UINT msi_set_last_used_source(LPCWSTR product, LPCWSTR usersid,
|
||||
MSIINSTALLCONTEXT context, DWORD options,
|
||||
LPCWSTR value)
|
||||
{
|
||||
HKEY source;
|
||||
LPWSTR buffer;
|
||||
WCHAR typechar;
|
||||
DWORD size;
|
||||
UINT r;
|
||||
int index = 0;
|
||||
int index = 1;
|
||||
|
||||
static const WCHAR format[] = {'%','c',';','%','i',';','%','s',0};
|
||||
|
||||
|
@ -717,27 +718,36 @@ static UINT set_last_used_source(HKEY source, LPCWSTR product, LPCWSTR usersid,
|
|||
typechar = 'n';
|
||||
else if (options & MSISOURCETYPE_URL)
|
||||
typechar = 'u';
|
||||
else if (options & MSISOURCETYPE_MEDIA)
|
||||
typechar = 'm';
|
||||
else
|
||||
return ERROR_INVALID_PARAMETER;
|
||||
|
||||
/* make sure the source is registered */
|
||||
r = MsiSourceListAddSourceExW(product, usersid, context,
|
||||
options, value, 0);
|
||||
if (r != ERROR_SUCCESS)
|
||||
return r;
|
||||
if (!(options & MSISOURCETYPE_MEDIA))
|
||||
{
|
||||
r = MsiSourceListAddSourceExW(product, usersid, context,
|
||||
options, value, 0);
|
||||
if (r != ERROR_SUCCESS)
|
||||
return r;
|
||||
|
||||
while ((r = MsiSourceListEnumSourcesW(product, usersid, context, options,
|
||||
index, NULL, NULL)) == ERROR_SUCCESS)
|
||||
index++;
|
||||
index = 0;
|
||||
while ((r = MsiSourceListEnumSourcesW(product, usersid, context, options,
|
||||
index, NULL, NULL)) == ERROR_SUCCESS)
|
||||
index++;
|
||||
|
||||
if (r != ERROR_NO_MORE_ITEMS)
|
||||
return r;
|
||||
if (r != ERROR_NO_MORE_ITEMS)
|
||||
return r;
|
||||
}
|
||||
|
||||
size = (lstrlenW(format) + lstrlenW(value) + 7) * sizeof(WCHAR);
|
||||
buffer = msi_alloc(size);
|
||||
if (!buffer)
|
||||
return ERROR_OUTOFMEMORY;
|
||||
|
||||
r = OpenSourceKey(product, &source, MSICODE_PRODUCT, context, FALSE);
|
||||
if (r != ERROR_SUCCESS)
|
||||
return r;
|
||||
|
||||
sprintfW(buffer, format, typechar, index, value);
|
||||
|
||||
size = (lstrlenW(buffer) + 1) * sizeof(WCHAR);
|
||||
|
@ -745,6 +755,7 @@ static UINT set_last_used_source(HKEY source, LPCWSTR product, LPCWSTR usersid,
|
|||
REG_SZ, (LPBYTE)buffer, size);
|
||||
msi_free(buffer);
|
||||
|
||||
RegCloseKey(source);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -818,15 +829,19 @@ UINT WINAPI MsiSourceListSetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
|
|||
if (rc != ERROR_SUCCESS)
|
||||
rc = ERROR_UNKNOWN_PROPERTY;
|
||||
}
|
||||
else if (strcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW)==0)
|
||||
rc = set_last_used_source(sourcekey, szProduct, szUserSid, dwContext,
|
||||
dwOptions, szValue);
|
||||
else if (!lstrcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW))
|
||||
{
|
||||
if (!(dwOptions & (MSISOURCETYPE_NETWORK | MSISOURCETYPE_URL)))
|
||||
rc = ERROR_INVALID_PARAMETER;
|
||||
else
|
||||
rc = msi_set_last_used_source(szProduct, szUserSid, dwContext,
|
||||
dwOptions, szValue);
|
||||
}
|
||||
else
|
||||
rc = ERROR_UNKNOWN_PROPERTY;
|
||||
|
||||
RegCloseKey(sourcekey);
|
||||
return rc;
|
||||
|
||||
}
|
||||
|
||||
/******************************************************************
|
||||
|
|
Loading…
Reference in New Issue