Commit 0713c328 authored by James Hawkins's avatar James Hawkins Committed by Alexandre Julliard

msi: Implement the remaining contexts for MsiQueryComponentState.

parent 1f3133d2
...@@ -770,6 +770,11 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode, ...@@ -770,6 +770,11 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
DWORD sz; DWORD sz;
UINT r; 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), TRACE("(%s, %s, %d, %s, %p)\n", debugstr_w(szProductCode),
debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState); debugstr_w(szUserSid), dwContext, debugstr_w(szComponent), pdwState);
...@@ -783,34 +788,46 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode, ...@@ -783,34 +788,46 @@ UINT WINAPI MsiQueryComponentStateW(LPCWSTR szProductCode,
return ERROR_INVALID_PARAMETER; return ERROR_INVALID_PARAMETER;
if (dwContext == MSIINSTALLCONTEXT_MACHINE) if (dwContext == MSIINSTALLCONTEXT_MACHINE)
{
r = MSIREG_OpenLocalSystemProductKey(szProductCode, &hkey, FALSE); r = MSIREG_OpenLocalSystemProductKey(szProductCode, &hkey, FALSE);
if (r != ERROR_SUCCESS) else
return ERROR_UNKNOWN_PRODUCT; r = MSIREG_OpenInstallPropertiesKey(szProductCode, &hkey, FALSE);
RegCloseKey(hkey); if (r != ERROR_SUCCESS)
*pdwState = INSTALLSTATE_UNKNOWN; 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); r = MSIREG_OpenLocalSystemComponentKey(szComponent, &hkey, FALSE);
if (r != ERROR_SUCCESS) else
return ERROR_UNKNOWN_COMPONENT; r = MSIREG_OpenUserDataComponentKey(szComponent, &hkey, FALSE);
sz = 0; if (r != ERROR_SUCCESS)
res = RegQueryValueExW(hkey, squished_pc, NULL, NULL, NULL, &sz); return ERROR_UNKNOWN_COMPONENT;
if (res != 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) RegCloseKey(hkey);
*pdwState = INSTALLSTATE_NOTUSED;
else
*pdwState = INSTALLSTATE_LOCAL;
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) INSTALLSTATE WINAPI MsiQueryProductStateA(LPCSTR szProduct)
......
...@@ -1876,7 +1876,10 @@ static void test_publish(void) ...@@ -1876,7 +1876,10 @@ static void test_publish(void)
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
"{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
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 == 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 */ /* PublishProduct and RegisterProduct and ProcessComponents */
r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1"); r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1");
...@@ -1931,7 +1934,10 @@ static void test_publish(void) ...@@ -1931,7 +1934,10 @@ static void test_publish(void)
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
"{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
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 == 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 */ /* PublishProduct, RegisterProduct, ProcessComponents, PublishFeatures */
r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1"); r = MsiInstallProductA(msifile, "REGISTER_PRODUCT=1 PUBLISH_PRODUCT=1 PROCESS_COMPONENTS=1 PUBLISH_FEATURES=1");
...@@ -1989,7 +1995,10 @@ static void test_publish(void) ...@@ -1989,7 +1995,10 @@ static void test_publish(void)
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
"{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
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 == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); todo_wine
{
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
}
/* complete install */ /* complete install */
r = MsiInstallProductA(msifile, "FULL=1"); r = MsiInstallProductA(msifile, "FULL=1");
...@@ -2047,7 +2056,10 @@ static void test_publish(void) ...@@ -2047,7 +2056,10 @@ static void test_publish(void)
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
"{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
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 == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); todo_wine
{
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
}
/* complete install */ /* complete install */
r = MsiInstallProductA(msifile, "FULL=1"); r = MsiInstallProductA(msifile, "FULL=1");
...@@ -2163,7 +2175,10 @@ static void test_publish(void) ...@@ -2163,7 +2175,10 @@ static void test_publish(void)
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
"{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
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 == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); todo_wine
{
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
}
/* complete install */ /* complete install */
r = MsiInstallProductA(msifile, "FULL=1"); r = MsiInstallProductA(msifile, "FULL=1");
...@@ -2221,7 +2236,10 @@ static void test_publish(void) ...@@ -2221,7 +2236,10 @@ static void test_publish(void)
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
"{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state); "{DF2CBABC-3BCC-47E5-A998-448D1C0C895B}", &state);
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 == 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 */ /* make sure 'Program Files\msitest' is removed */
delete_pfmsitest_files(); delete_pfmsitest_files();
......
...@@ -755,10 +755,7 @@ static void test_MsiQueryComponentState(void) ...@@ -755,10 +755,7 @@ static void test_MsiQueryComponentState(void)
state = 0xdeadbeef; state = 0xdeadbeef;
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); 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); ok(state == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", state);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\"); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
...@@ -776,10 +773,7 @@ static void test_MsiQueryComponentState(void) ...@@ -776,10 +773,7 @@ static void test_MsiQueryComponentState(void)
state = 0xdeadbeef; state = 0xdeadbeef;
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r); 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\\"); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
lstrcatA(keypath, usersid); lstrcatA(keypath, usersid);
...@@ -793,10 +787,7 @@ static void test_MsiQueryComponentState(void) ...@@ -793,10 +787,7 @@ static void test_MsiQueryComponentState(void)
state = 0xdeadbeef; state = 0xdeadbeef;
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state);
ok(r == ERROR_UNKNOWN_COMPONENT, "Expected ERROR_UNKNOWN_COMPONENT, got %d\n", r); 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); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 0);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
...@@ -804,31 +795,22 @@ static void test_MsiQueryComponentState(void) ...@@ -804,31 +795,22 @@ static void test_MsiQueryComponentState(void)
/* component\product exists */ /* component\product exists */
state = 0xdeadbeef; state = 0xdeadbeef;
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); 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); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"hi", 2);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = 0xdeadbeef; state = 0xdeadbeef;
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, component, &state); 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 */ /* MSIINSTALLCONTEXT_USERMANAGED */
state = 0xdeadbeef; state = 0xdeadbeef;
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state); 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); ok(state == 0xdeadbeef, "Expected 0xdeadbeef, got %d\n", state);
res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11); res = RegSetValueExA(prodkey, "ManagedLocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
...@@ -836,11 +818,8 @@ static void test_MsiQueryComponentState(void) ...@@ -836,11 +818,8 @@ static void test_MsiQueryComponentState(void)
state = 0xdeadbeef; state = 0xdeadbeef;
r = MsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_USERMANAGED, component, &state); 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, "LocalPackage");
RegDeleteValueA(prodkey, "ManagedLocalPackage"); RegDeleteValueA(prodkey, "ManagedLocalPackage");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment