[PRINTING]

SetDefaultPrinterW needs to fail with ERROR_INVALID_PRINTER_NAME if the input parameter is invalid. Also add a test for that.

svn path=/trunk/; revision=74518
This commit is contained in:
Colin Finck 2017-05-10 13:03:08 +00:00
parent 643b7c9da9
commit a366e71f50
2 changed files with 6 additions and 1 deletions

View file

@ -817,7 +817,7 @@ SetDefaultPrinterW(LPCWSTR pszPrinter)
dwErrorCode = (DWORD)RegQueryValueExW(hDevicesKey, pszPrinter, NULL, NULL, NULL, &cbPrinterValueData);
if (dwErrorCode == ERROR_FILE_NOT_FOUND)
{
// The caller gave us an invalid printer name, return with ERROR_FILE_NOT_FOUND.
dwErrorCode = ERROR_INVALID_PRINTER_NAME;
goto Cleanup;
}
else if (dwErrorCode != ERROR_SUCCESS)

View file

@ -45,5 +45,10 @@ START_TEST(GetDefaultPrinter)
ok(SetDefaultPrinterW(pwszDefaultPrinter), "SetDefaultPrinterW returns FALSE!\n");
ok(GetLastError() == ERROR_SUCCESS, "SetDefaultPrinterW returns error %lu!\n", GetLastError());
// SetDefaultPrinterW with an invalid printer name needs to fail with ERROR_INVALID_PRINTER_NAME.
SetLastError(0xDEADBEEF);
ok(!SetDefaultPrinterW(L"INVALID PRINTER NAME!!!"), "SetDefaultPrinterW returns TRUE!\n");
ok(GetLastError() == ERROR_INVALID_PRINTER_NAME, "SetDefaultPrinterW returns error %lu!\n", GetLastError());
HeapFree(GetProcessHeap(), 0, pwszDefaultPrinter);
}