Commit ad6b7cd4 authored by Hans Leidekker's avatar Hans Leidekker Committed by Alexandre Julliard

msi: Clear last error on success in MsiQueryFeatureState and MsiQueryProductState.

parent d2055e6e
...@@ -1980,6 +1980,11 @@ INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct) ...@@ -1980,6 +1980,11 @@ INSTALLSTATE WINAPI MsiQueryProductStateW(LPCWSTR szProduct)
if (lstrlenW(szProduct) != GUID_SIZE - 1) if (lstrlenW(szProduct) != GUID_SIZE - 1)
return INSTALLSTATE_INVALIDARG; return INSTALLSTATE_INVALIDARG;
if (szProduct[0] != '{' || szProduct[37] != '}')
return INSTALLSTATE_UNKNOWN;
SetLastError( ERROR_SUCCESS );
if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED, if (MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERMANAGED,
&prodkey, FALSE) != ERROR_SUCCESS && &prodkey, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED, MSIREG_OpenProductKey(szProduct, NULL, MSIINSTALLCONTEXT_USERUNMANAGED,
...@@ -2629,6 +2634,8 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature) ...@@ -2629,6 +2634,8 @@ INSTALLSTATE WINAPI MsiQueryFeatureStateW(LPCWSTR szProduct, LPCWSTR szFeature)
if (!squash_guid( szProduct, squishProduct )) if (!squash_guid( szProduct, squishProduct ))
return INSTALLSTATE_INVALIDARG; return INSTALLSTATE_INVALIDARG;
SetLastError( ERROR_SUCCESS );
if (MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED, if (MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERMANAGED,
&hkey, FALSE) != ERROR_SUCCESS && &hkey, FALSE) != ERROR_SUCCESS &&
MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED, MSIREG_OpenFeaturesKey(szProduct, MSIINSTALLCONTEXT_USERUNMANAGED,
......
...@@ -573,7 +573,7 @@ static void test_MsiQueryProductState(void) ...@@ -573,7 +573,7 @@ static void test_MsiQueryProductState(void)
LONG res; LONG res;
HKEY userkey, localkey, props; HKEY userkey, localkey, props;
HKEY prodkey; HKEY prodkey;
DWORD data; DWORD data, error;
REGSAM access = KEY_ALL_ACCESS; REGSAM access = KEY_ALL_ACCESS;
create_test_guid(prodcode, prod_squashed); create_test_guid(prodcode, prod_squashed);
...@@ -583,33 +583,56 @@ static void test_MsiQueryProductState(void) ...@@ -583,33 +583,56 @@ static void test_MsiQueryProductState(void)
access |= KEY_WOW64_64KEY; access |= KEY_WOW64_64KEY;
/* NULL prodcode */ /* NULL prodcode */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(NULL); state = MsiQueryProductStateA(NULL);
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* empty prodcode */ /* empty prodcode */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(""); state = MsiQueryProductStateA("");
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* garbage prodcode */ /* garbage prodcode */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA("garbage"); state = MsiQueryProductStateA("garbage");
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* guid without brackets */ /* guid without brackets */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D"); state = MsiQueryProductStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D");
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* guid with brackets */ /* guid with brackets */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}"); state = MsiQueryProductStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}");
error = GetLastError();
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
/* same length as guid, but random */ /* same length as guid, but random */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93"); state = MsiQueryProductStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93");
error = GetLastError();
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* MSIINSTALLCONTEXT_USERUNMANAGED */ /* MSIINSTALLCONTEXT_USERUNMANAGED */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\"); lstrcpyA(keypath, "Software\\Microsoft\\Installer\\Products\\");
lstrcatA(keypath, prod_squashed); lstrcatA(keypath, prod_squashed);
...@@ -618,8 +641,12 @@ static void test_MsiQueryProductState(void) ...@@ -618,8 +641,12 @@ static void test_MsiQueryProductState(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* user product key exists */ /* user product key exists */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\"); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Uninstall\\");
lstrcatA(keypath, prodcode); lstrcatA(keypath, prodcode);
...@@ -635,16 +662,24 @@ static void test_MsiQueryProductState(void) ...@@ -635,16 +662,24 @@ static void test_MsiQueryProductState(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local uninstall key exists */ /* local uninstall key exists */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
data = 1; data = 1;
res = RegSetValueExA(localkey, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD)); res = RegSetValueExA(localkey, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* WindowsInstaller value exists */ /* WindowsInstaller value exists */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
RegDeleteValueA(localkey, "WindowsInstaller"); RegDeleteValueA(localkey, "WindowsInstaller");
delete_key(localkey, "", access & KEY_WOW64_64KEY); delete_key(localkey, "", access & KEY_WOW64_64KEY);
...@@ -658,37 +693,57 @@ static void test_MsiQueryProductState(void) ...@@ -658,37 +693,57 @@ static void test_MsiQueryProductState(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* local product key exists */ /* local product key exists */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL); res = RegCreateKeyExA(localkey, "InstallProperties", 0, NULL, 0, access, NULL, &props, NULL);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* install properties key exists */ /* install properties key exists */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
data = 1; data = 1;
res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD)); res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* WindowsInstaller value exists */ /* WindowsInstaller value exists */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state); ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
data = 2; data = 2;
res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD)); res = RegSetValueExA(props, "WindowsInstaller", 0, REG_DWORD, (const BYTE *)&data, sizeof(DWORD));
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* WindowsInstaller value is not 1 */ /* WindowsInstaller value is not 1 */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state); ok(state == INSTALLSTATE_DEFAULT, "Expected INSTALLSTATE_DEFAULT, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
RegDeleteKeyA(userkey, ""); RegDeleteKeyA(userkey, "");
/* user product key does not exist */ /* user product key does not exist */
SetLastError(0xdeadbeef);
state = MsiQueryProductStateA(prodcode); state = MsiQueryProductStateA(prodcode);
error = GetLastError();
ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state); ok(state == INSTALLSTATE_ABSENT, "Expected INSTALLSTATE_ABSENT, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
RegDeleteValueA(props, "WindowsInstaller"); RegDeleteValueA(props, "WindowsInstaller");
delete_key(props, "", access & KEY_WOW64_64KEY); delete_key(props, "", access & KEY_WOW64_64KEY);
...@@ -860,6 +915,7 @@ static void test_MsiQueryFeatureState(void) ...@@ -860,6 +915,7 @@ static void test_MsiQueryFeatureState(void)
LPSTR usersid; LPSTR usersid;
LONG res; LONG res;
REGSAM access = KEY_ALL_ACCESS; REGSAM access = KEY_ALL_ACCESS;
DWORD error;
create_test_guid(prodcode, prod_squashed); create_test_guid(prodcode, prod_squashed);
compose_base85_guid(component, comp_base85, comp_squashed); compose_base85_guid(component, comp_base85, comp_squashed);
...@@ -870,40 +926,69 @@ static void test_MsiQueryFeatureState(void) ...@@ -870,40 +926,69 @@ static void test_MsiQueryFeatureState(void)
access |= KEY_WOW64_64KEY; access |= KEY_WOW64_64KEY;
/* NULL prodcode */ /* NULL prodcode */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(NULL, "feature"); state = MsiQueryFeatureStateA(NULL, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* empty prodcode */ /* empty prodcode */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA("", "feature"); state = MsiQueryFeatureStateA("", "feature");
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* garbage prodcode */ /* garbage prodcode */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA("garbage", "feature"); state = MsiQueryFeatureStateA("garbage", "feature");
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* guid without brackets */ /* guid without brackets */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature"); state = MsiQueryFeatureStateA("6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D", "feature");
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* guid with brackets */ /* guid with brackets */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature"); state = MsiQueryFeatureStateA("{6700E8CF-95AB-4D9C-BC2C-15840DEA7A5D}", "feature");
error = GetLastError();
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == ERROR_SUCCESS, "expected ERROR_SUCCESS, got %u\n", error);
/* same length as guid, but random */ /* same length as guid, but random */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature"); state = MsiQueryFeatureStateA("A938G02JF-2NF3N93-VN3-2NNF-3KGKALDNF93", "feature");
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* NULL szFeature */ /* NULL szFeature */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, NULL); state = MsiQueryFeatureStateA(prodcode, NULL);
error = GetLastError();
ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state); ok(state == INSTALLSTATE_INVALIDARG, "Expected INSTALLSTATE_INVALIDARG, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* empty szFeature */ /* empty szFeature */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, ""); state = MsiQueryFeatureStateA(prodcode, "");
error = GetLastError();
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
/* feature key does not exist yet */ /* feature key does not exist yet */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
/* MSIINSTALLCONTEXT_USERUNMANAGED */ /* MSIINSTALLCONTEXT_USERUNMANAGED */
...@@ -914,15 +999,23 @@ static void test_MsiQueryFeatureState(void) ...@@ -914,15 +999,23 @@ static void test_MsiQueryFeatureState(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* feature key exists */ /* feature key exists */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2); res = RegSetValueExA(userkey, "feature", 0, REG_SZ, (const BYTE *)"", 2);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* feature value exists */ /* feature value exists */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\"); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
lstrcatA(keypath, usersid); lstrcatA(keypath, usersid);
...@@ -942,32 +1035,52 @@ static void test_MsiQueryFeatureState(void) ...@@ -942,32 +1035,52 @@ static void test_MsiQueryFeatureState(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* userdata features key exists */ /* userdata features key exists */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20); res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaa", 20);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state); ok(state == INSTALLSTATE_BADCONFIG, "Expected INSTALLSTATE_BADCONFIG, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21); res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaa", 21);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22); res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)"aaaaaaaaaaaaaaaaaaaaa", 22);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41); res = RegSetValueExA(localkey, "feature", 0, REG_SZ, (const BYTE *)comp_base85, 41);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\"); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\");
lstrcatA(keypath, usersid); lstrcatA(keypath, usersid);
...@@ -985,55 +1098,87 @@ static void test_MsiQueryFeatureState(void) ...@@ -985,55 +1098,87 @@ static void test_MsiQueryFeatureState(void)
res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey2, NULL); res = RegCreateKeyExA(HKEY_LOCAL_MACHINE, keypath, 0, NULL, 0, access, NULL, &compkey2, NULL);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"", 1);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"apple", 6);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state); ok(state == INSTALLSTATE_ADVERTISED, "Expected INSTALLSTATE_ADVERTISED, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7); res = RegSetValueExA(compkey2, prod_squashed, 0, REG_SZ, (const BYTE *)"orange", 7);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* INSTALLSTATE_LOCAL */ /* INSTALLSTATE_LOCAL */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* INSTALLSTATE_SOURCE */ /* INSTALLSTATE_SOURCE */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state); ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* bad INSTALLSTATE_SOURCE */ /* bad INSTALLSTATE_SOURCE */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* INSTALLSTATE_SOURCE */ /* INSTALLSTATE_SOURCE */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state); ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* bad INSTALLSTATE_SOURCE */ /* bad INSTALLSTATE_SOURCE */
SetLastError(0xdeadbeef);
state = MsiQueryFeatureStateA(prodcode, "feature"); state = MsiQueryFeatureStateA(prodcode, "feature");
error = GetLastError();
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(error == ERROR_SUCCESS || broken(error == ERROR_NO_TOKEN) /* win2k */,
"expected ERROR_SUCCESS, got %u\n", error);
RegDeleteValueA(compkey, prod_squashed); RegDeleteValueA(compkey, prod_squashed);
RegDeleteValueA(compkey2, prod_squashed); RegDeleteValueA(compkey2, prod_squashed);
...@@ -1272,6 +1417,7 @@ static void test_MsiQueryComponentState(void) ...@@ -1272,6 +1417,7 @@ static void test_MsiQueryComponentState(void)
LONG res; LONG res;
UINT r; UINT r;
REGSAM access = KEY_ALL_ACCESS; REGSAM access = KEY_ALL_ACCESS;
DWORD error;
static const INSTALLSTATE MAGIC_ERROR = 0xdeadbeef; static const INSTALLSTATE MAGIC_ERROR = 0xdeadbeef;
...@@ -1290,44 +1436,65 @@ static void test_MsiQueryComponentState(void) ...@@ -1290,44 +1436,65 @@ static void test_MsiQueryComponentState(void)
/* NULL szProductCode */ /* NULL szProductCode */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(NULL, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(NULL, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state); ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* empty szProductCode */ /* empty szProductCode */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA("", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA("", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state); ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* random szProductCode */ /* random szProductCode */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA("random", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA("random", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state); ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* GUID-length szProductCode */ /* GUID-length szProductCode */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA("DJANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KDE", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state); ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* GUID-length with brackets */ /* GUID-length with brackets */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA("{JANE93KNDNAS-2KN2NR93KMN3LN13=L1N3KD}", NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state); ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* actual GUID */ /* actual GUID */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
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 == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state); ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
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 == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state); ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\"); lstrcpyA(keypath, "Software\\Classes\\Installer\\Products\\");
lstrcatA(keypath, prod_squashed); lstrcatA(keypath, prod_squashed);
...@@ -1342,9 +1509,12 @@ static void test_MsiQueryComponentState(void) ...@@ -1342,9 +1509,12 @@ static void test_MsiQueryComponentState(void)
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
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);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
delete_key(prodkey, "", access & KEY_WOW64_64KEY); delete_key(prodkey, "", access & KEY_WOW64_64KEY);
RegCloseKey(prodkey); RegCloseKey(prodkey);
...@@ -1360,17 +1530,22 @@ static void test_MsiQueryComponentState(void) ...@@ -1360,17 +1530,22 @@ static void test_MsiQueryComponentState(void)
/* local system product key exists */ /* local system product key exists */
state = MAGIC_ERROR; state = MAGIC_ERROR;
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
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 == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state); ok(state == MAGIC_ERROR, "Expected 0xdeadbeef, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11); res = RegSetValueExA(prodkey, "LocalPackage", 0, REG_SZ, (const BYTE *)"msitest.msi", 11);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* LocalPackage value exists */ /* LocalPackage value exists */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
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);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\"); lstrcpyA(keypath, "Software\\Microsoft\\Windows\\CurrentVersion\\Installer\\UserData\\S-1-5-18\\Components\\");
lstrcatA(keypath, comp_squashed); lstrcatA(keypath, comp_squashed);
...@@ -1380,70 +1555,94 @@ static void test_MsiQueryComponentState(void) ...@@ -1380,70 +1555,94 @@ static void test_MsiQueryComponentState(void)
/* component key exists */ /* component key exists */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
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);
ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state); ok(state == INSTALLSTATE_UNKNOWN, "Expected INSTALLSTATE_UNKNOWN, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
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);
/* component\product exists */ /* component\product exists */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
error = GetLastError();
ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL, ok(state == INSTALLSTATE_NOTUSED || state == INSTALLSTATE_LOCAL,
"Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state); "Expected INSTALLSTATE_NOTUSED or INSTALLSTATE_LOCAL, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
/* NULL component, product exists */ /* NULL component, product exists */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, NULL, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, NULL, &state);
error = GetLastError();
ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r); ok(r == ERROR_INVALID_PARAMETER, "Expected ERROR_INVALID_PARAMETER, got %d\n", r);
ok(state == MAGIC_ERROR, "Expected state not changed, got %d\n", state); ok(state == MAGIC_ERROR, "Expected state not changed, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
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);
/* INSTALLSTATE_LOCAL */ /* INSTALLSTATE_LOCAL */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01\\", 4);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* INSTALLSTATE_SOURCE */ /* INSTALLSTATE_SOURCE */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state); ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* bad INSTALLSTATE_SOURCE */ /* bad INSTALLSTATE_SOURCE */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01a", 4);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* INSTALLSTATE_SOURCE */ /* INSTALLSTATE_SOURCE */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state); ok(state == INSTALLSTATE_SOURCE, "Expected INSTALLSTATE_SOURCE, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3); res = RegSetValueExA(compkey, prod_squashed, 0, REG_SZ, (const BYTE *)"01", 3);
ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res); ok(res == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", res);
/* bad INSTALLSTATE_SOURCE */ /* bad INSTALLSTATE_SOURCE */
state = MAGIC_ERROR; state = MAGIC_ERROR;
SetLastError(0xdeadbeef);
r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state); r = pMsiQueryComponentStateA(prodcode, NULL, MSIINSTALLCONTEXT_MACHINE, component, &state);
error = GetLastError();
ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r); ok(r == ERROR_SUCCESS, "Expected ERROR_SUCCESS, got %d\n", r);
ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state); ok(state == INSTALLSTATE_LOCAL, "Expected INSTALLSTATE_LOCAL, got %d\n", state);
ok(error == 0xdeadbeef, "expected 0xdeadbeef, got %u\n", error);
RegDeleteValueA(prodkey, "LocalPackage"); RegDeleteValueA(prodkey, "LocalPackage");
delete_key(prodkey, "", access & KEY_WOW64_64KEY); delete_key(prodkey, "", access & KEY_WOW64_64KEY);
......
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