Zhiyi Zhang (@zhiyi) commented about dlls/uxtheme/tests/system.c:
- /* Call ShouldSystemUseDarkMode() and check for errors */
- SetLastError(ERROR_SUCCESS); /* Clear error buffer so that we can detect if an error occurred. */
- function_result = pShouldSystemUseDarkMode();
- last_error = GetLastError();
- ok(last_error == ERROR_SUCCESS, "ShouldSystemUseDarkMode failed (?) with error %ld.\n",
last_error);
- /* Expect same value as key */
- ok(function_result == !system_uses_light_theme, "Expected value %d, got %d.\n",
!system_uses_light_theme, function_result);
- ls = RegDeleteValueA(hk, "AppsUseLightTheme");
- ok(ls == 0, "RegDeleteValueA failed: %ld.\n", ls);
- /* Call ShouldSystemUseDarkMode() and check for errors with deleted value */
- SetLastError(ERROR_SUCCESS); /* Clear error buffer so that we can detect if an error occurred. */
For the last error code. You can SetLastError(0xdeadbeef) before the call and check that the last error is set to ERROR_SUCCESS after the call. And then you set the last error code in the ShouldSystemUseDarkMode() implementation.