msi: Allow enumerating the sources without querying the source name.

This commit is contained in:
James Hawkins 2008-02-21 00:03:25 -06:00 committed by Alexandre Julliard
parent 3de0014750
commit 6c7339eea1
2 changed files with 17 additions and 4 deletions

View File

@ -189,12 +189,13 @@ UINT WINAPI MsiSourceListEnumSourcesA(LPCSTR szProductCodeOrPatch, LPCSTR szUser
goto done;
len = WideCharToMultiByte(CP_ACP, 0, source, -1, NULL, 0, NULL, NULL);
if (*pcchSource >= len)
if (pcchSource && *pcchSource >= len)
WideCharToMultiByte(CP_ACP, 0, source, -1, szSource, len, NULL, NULL);
else if (szSource)
r = ERROR_MORE_DATA;
*pcchSource = len - 1;
if (pcchSource)
*pcchSource = len - 1;
done:
msi_free(product);
@ -203,7 +204,7 @@ done:
if (r == ERROR_SUCCESS)
{
if (szSource) index++;
if (szSource || !pcchSource) index++;
}
else if (dwIndex > index)
index = 0;
@ -281,7 +282,7 @@ done:
if (r == ERROR_SUCCESS)
{
if (szSource) index++;
if (szSource || !pcchSource) index++;
}
else if (dwIndex > index)
index = 0;

View File

@ -883,6 +883,18 @@ static void test_MsiSourceListEnumSources(void)
ok(!lstrcmpA(value, "first"), "Expected \"first\", got %s\n", value);
ok(size == 5, "Expected 5, got %d\n", size);
/* both szSource and pcchSource are NULL, index 0 */
r = MsiSourceListEnumSourcesA(prodcode, usersid,
MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT | MSISOURCETYPE_URL, 0, NULL, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
/* both szSource and pcchSource are NULL, index 1 */
r = MsiSourceListEnumSourcesA(prodcode, usersid,
MSIINSTALLCONTEXT_USERUNMANAGED,
MSICODE_PRODUCT | MSISOURCETYPE_URL, 1, NULL, NULL);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
/* size is exactly 5 */
size = 5;
lstrcpyA(value, "aaa");