msi: Factorize and fix the INSTALLPROPERTY_MEDIAPACKAGEPATH case.

This commit is contained in:
James Hawkins 2008-02-24 20:04:19 -06:00 committed by Alexandre Julliard
parent f178985db3
commit d41cae07d5
3 changed files with 34 additions and 33 deletions

View File

@ -352,9 +352,12 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
LPDWORD pcchValue)
{
WCHAR squished_pc[GUID_SIZE];
HKEY sourcekey;
HKEY sourcekey, media;
UINT rc;
static const WCHAR mediapack[] = {
'M','e','d','i','a','P','a','c','k','a','g','e',0};
TRACE("%s %s\n", debugstr_w(szProduct), debugstr_w(szProperty));
if (!szProduct || !squash_guid(szProduct, squished_pc))
@ -381,27 +384,21 @@ UINT WINAPI MsiSourceListGetInfoW( LPCWSTR szProduct, LPCWSTR szUserSid,
if (rc != ERROR_SUCCESS)
return rc;
if (strcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW) == 0)
if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW) ||
!lstrcmpW(szProperty, INSTALLPROPERTY_DISKPROMPTW))
{
HKEY key;
rc = OpenMediaSubkey(sourcekey, &key, FALSE);
if (rc == ERROR_SUCCESS)
rc = RegQueryValueExW(key, INSTALLPROPERTY_MEDIAPACKAGEPATHW,
0, 0, (LPBYTE)szValue, pcchValue);
if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA)
rc = ERROR_UNKNOWN_PROPERTY;
RegCloseKey(key);
}
else if (strcmpW(szProperty, INSTALLPROPERTY_DISKPROMPTW) ==0)
{
HKEY key;
rc = OpenMediaSubkey(sourcekey, &key, FALSE);
if (rc == ERROR_SUCCESS)
rc = RegQueryValueExW(key, INSTALLPROPERTY_DISKPROMPTW, 0, 0,
(LPBYTE)szValue, pcchValue);
if (rc != ERROR_SUCCESS && rc != ERROR_MORE_DATA)
rc = ERROR_UNKNOWN_PROPERTY;
RegCloseKey(key);
rc = OpenMediaSubkey(sourcekey, &media, FALSE);
if (rc != ERROR_SUCCESS)
{
RegCloseKey(sourcekey);
return ERROR_SUCCESS;
}
if (!lstrcmpW(szProperty, INSTALLPROPERTY_MEDIAPACKAGEPATHW))
szProperty = mediapack;
RegQueryValueExW(media, szProperty, 0, 0, (LPBYTE)szValue, pcchValue);
RegCloseKey(media);
}
else if (strcmpW(szProperty, INSTALLPROPERTY_LASTUSEDSOURCEW)==0)
{

View File

@ -2998,12 +2998,9 @@ static void test_publishsourcelist(void)
lstrcpyA(value, "aaa");
r = pMsiSourceListGetInfoA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT, INSTALLPROPERTY_MEDIAPACKAGEPATH, value, &size);
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
ok(size == 0, "Expected 0, got %d\n", size);
}
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
ok(size == 0, "Expected 0, got %d\n", size);
size = MAX_PATH;
lstrcpyA(value, "aaa");

View File

@ -332,6 +332,16 @@ static void test_MsiSourceListGetInfo(void)
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(size == 11, "Expected 11, got %d\n", size);
/* INSTALLPROPERTY_MEDIAPACKAGEPATH, media key does not exist */
size = MAX_PATH;
lstrcpyA(value, "aaa");
r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT, INSTALLPROPERTY_MEDIAPACKAGEPATH,
value, &size);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(value, ""), "Expected \"\", got \"%s\"\n", value);
ok(size == 0, "Expected 0, got %d\n", size);
res = RegCreateKeyA(hkey, "Media", &media);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
@ -345,12 +355,9 @@ static void test_MsiSourceListGetInfo(void)
r = pMsiSourceListGetInfoA(prodcode, usersid, MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT, INSTALLPROPERTY_MEDIAPACKAGEPATH,
value, &size);
todo_wine
{
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(value, "path"), "Expected \"path\", got \"%s\"\n", value);
ok(size == 4, "Expected 4, got %d\n", size);
}
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(!lstrcmpA(value, "path"), "Expected \"path\", got \"%s\"\n", value);
ok(size == 4, "Expected 4, got %d\n", size);
/* INSTALLPROPERTY_DISKPROMPT */
data = "prompt";