[PATCH] localspl: Clear lasterror on success in AddMonitor, with test
Detlef Riekenberg
wine.dev at web.de
Mon Dec 5 15:44:34 CST 2016
This is ugly, but there are printmonitor installers,
which depend on GetLastError() even on success of AddMonitor
redmon is an example:
https://bugs.winehq.org/show_bug.cgi?id=3864#c22
Many Monitors depend on the example code from Microsoft, so...
--
bye bye ... Detlef
Signed-off-by: Detlef Riekenberg <wine.dev at web.de>
---
dlls/localspl/provider.c | 3 +++
dlls/winspool.drv/tests/info.c | 6 ++++++
2 files changed, 9 insertions(+)
diff --git a/dlls/localspl/provider.c b/dlls/localspl/provider.c
index f359b73..f370b9f 100644
--- a/dlls/localspl/provider.c
+++ b/dlls/localspl/provider.c
@@ -1541,6 +1541,9 @@ static BOOL WINAPI fpAddMonitor(LPWSTR pName, DWORD Level, LPBYTE pMonitors)
RegCloseKey(hentry);
}
+ if (res)
+ SetLastError(ERROR_SUCCESS); /* Monitor installer depend on this */
+
RegCloseKey(hroot);
return (res);
}
diff --git a/dlls/winspool.drv/tests/info.c b/dlls/winspool.drv/tests/info.c
index f6527c5..602e935 100644
--- a/dlls/winspool.drv/tests/info.c
+++ b/dlls/winspool.drv/tests/info.c
@@ -435,6 +435,12 @@ static void test_AddMonitor(void)
SetLastError(MAGIC_DEAD);
res = AddMonitorA(NULL, 2, (LPBYTE) &mi2a);
ok(res, "returned %d with %d (expected '!= 0')\n", res, GetLastError());
+ if (res)
+ {
+ /* Some apps depend on the result of GetLastError() */
+ res = GetLastError();
+ ok(res == ERROR_SUCCESS, "got 0x%x/%u (expected ERROR_SUCCESS)\n", res, res);
+ }
/* add a monitor twice */
SetLastError(MAGIC_DEAD);
--
2.7.4
More information about the wine-patches
mailing list