From 0713c3286934e38704125f3a55748cf03b1756f1 Mon Sep 17 00:00:00 2001 From: James Hawkins Date: Tue, 7 Aug 2007 14:25:14 -0700 Subject: [PATCH] msi: Implement the remaining contexts for MsiQueryComponentState. --- dlls/msi/msi.c | 55 ++++++++++++++++++++++++++-------------- dlls/msi/tests/install.c | 30 +++++++++++++++++----- dlls/msi/tests/msi.c | 41 ++++++++---------------------- 3 files changed, 70 insertions(+), 56 deletions(-) diff --git a/dlls/msi/msi.c b/dlls/msi/msi.c index 115f71be10e..1b01a4de480 100644 --- a/dlls/msi/msi.c +++ b/dlls/msi/msi.c @@ -770,6 +770,11 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode, DWORD sz; UINT r; + static const WCHAR local_package[] = {'L','o','c','a','l','P','a','c','k','a','g','e',0}; + static const WCHAR managed_local_package[] = { + 'M','a','n','a','g','e','d','L','o','c','a','l','P','a','c','k','a','g','e',0 + }; + TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode), debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState); @@ -783,34 +788,46 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode, return ERROR_INVALID_PARAMETER; if (dwContext == MSIINSTALLCONTEXT_MACHINE) - { r = MSIREG_OpenLocalSystemProductKey(szProductCode, &hkey, FALSE); - if (r != ERROR_SUCCESS) - return ERROR_UNKNOWN_PRODUCT; + else + r = MSIREG_OpenInstallPropertiesKey(szProductCode, &hkey, FALSE); - RegCloseKey(hkey); - *pdwState = INSTALLSTATE_UNKNOWN; + if (r != ERROR_SUCCESS) + return ERROR_UNKNOWN_PRODUCT; + sz = 0; + if (dwContext != MSIINSTALLCONTEXT_USERMANAGED) + res = RegQueryValueExW(hkey, local_package, NULL, NULL, NULL, &sz); + else + res = RegQueryValueExW(hkey, managed_local_package, NULL, NULL, NULL, &sz); + + if (res != ERROR_SUCCESS) + return ERROR_UNKNOWN_PRODUCT; + + RegCloseKey(hkey); + *pdwState = INSTALLSTATE_UNKNOWN; + + if (dwContext == MSIINSTALLCONTEXT_MACHINE) r = MSIREG_OpenLocalSystemComponentKey(szComponent, &hkey, FALSE); - if (r != ERROR_SUCCESS) - return ERROR_UNKNOWN_COMPONENT; + else + r = MSIREG_OpenUserDataComponentKey(szComponent, &hkey, FALSE); - sz = 0; - res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, NULL, &sz); - if (res != ERROR_SUCCESS) - return ERROR_UNKNOWN_COMPONENT; + if (r != ERROR_SUCCESS) + return ERROR_UNKNOWN_COMPONENT; - RegCloseKey(hkey); + sz = 0; + res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, NULL, &sz); + if (res != ERROR_SUCCESS) + return ERROR_UNKNOWN_COMPONENT; - if (sz == 0) - *pdwState = INSTALLSTATE_NOTUSED; - else - *pdwState = INSTALLSTATE_LOCAL; + RegCloseKey(hkey); - return ERROR_SUCCESS; - } + if (sz == 0) + *pdwState = INSTALLSTATE_NOTUSED; + else + *pdwState = INSTALLSTATE_LOCAL; - return ERROR_UNKNOWN_COMPONENT; + return ERROR_SUCCESS; } INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct) diff --git a/dlls/msi/tests/install.c b/dlls/msi/tests/install.c index 164040f5d81..be54cdb3c29 100644 --- a/dlls/msi/tests/install.c +++ b/dlls/msi/tests/install.c @@ -1876,7 +1876,10 @@ static void test_publish(void) r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + todo_wine + { + ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + } /* PublishProduct and RegisterProduct and ProcessComponents */ r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1"); @@ -1931,7 +1934,10 @@ static void test_publish(void) r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + todo_wine + { + ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + } /* PublishProduct, RegisterProduct, ProcessComponents, PublishFeatures */ r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1"); @@ -1989,7 +1995,10 @@ static void test_publish(void) r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + todo_wine + { + ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + } /* complete install */ r = MsiInstallProductA(msifile, "FULL=1"); @@ -2047,7 +2056,10 @@ static void test_publish(void) r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + todo_wine + { + ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + } /* complete install */ r = MsiInstallProductA(msifile, "FULL=1"); @@ -2163,7 +2175,10 @@ static void test_publish(void) r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + todo_wine + { + ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + } /* complete install */ r = MsiInstallProductA(msifile, "FULL=1"); @@ -2221,7 +2236,10 @@ static void test_publish(void) r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + todo_wine + { + ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); + } /* make sure 'Program Files\msitest' is removed */ delete_pfmsitest_files(); diff --git a/dlls/msi/tests/msi.c b/dlls/msi/tests/msi.c index 5a95ade694b..f654aabe0d5 100644 --- a/dlls/msi/tests/msi.c +++ b/dlls/msi/tests/msi.c @@ -755,10 +755,7 @@ static void test_MsiQueryComponentState(void) state = 0xdeadbeef; r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); - todo_wine - { - ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - } + ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); ok(state == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", state); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\"); @@ -776,10 +773,7 @@ static void test_MsiQueryComponentState(void) state = 0xdeadbeef; r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r); - todo_wine - { - ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); - } + ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\"); lstrcatA(keypath, usersid); @@ -793,10 +787,7 @@ static void test_MsiQueryComponentState(void) state = 0xdeadbeef; r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r); - todo_wine - { - ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); - } + ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); @@ -804,31 +795,22 @@ static void test_MsiQueryComponentState(void) /* component\product exists */ state = 0xdeadbeef; r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); - todo_wine - { - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state); - } + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + ok(state == INSTALLSTATE_NOTUSED, "Expected INSTALLSTATE_NOTUSED, got %d\n", state); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); state = 0xdeadbeef; r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); - todo_wine - { - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); - } + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); /* MSIINSTALLCONTEXT_USERMANAGED */ state = 0xdeadbeef; r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state); - todo_wine - { - ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); - } + ok(r == ERROR_UNKNOWN_PRODUCT, "Expected ERROR_UNKNOWN_PRODUCT, got %d\n", r); ok(state == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", state); res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11); @@ -836,11 +818,8 @@ static void test_MsiQueryComponentState(void) state = 0xdeadbeef; r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state); - todo_wine - { - ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); - ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); - } + ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); + ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); RegDeleteValueA(prodkey, "LocalPackage"); RegDeleteValueA(prodkey, "ManagedLocalPackage");