Ensure default printer for windows backend.

This commit is contained in:
Armin Novak 2021-11-15 14:47:54 +01:00 committed by akallabeth
parent 46d524cbc7
commit 422b684957
1 changed files with 6 additions and 0 deletions

View File

@ -317,6 +317,7 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
int i;
PRINTER_INFO_2* prninfo = NULL;
DWORD needed, returned;
BOOL haveDefault = FALSE;
/* find required size for the buffer */
EnumPrinters(PRINTER_ENUM_LOCAL | PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed,
@ -353,9 +354,14 @@ static rdpPrinter** printer_win_enum_printers(rdpPrinterDriver* driver)
printers = NULL;
break;
}
if (current->is_default)
haveDefault = TRUE;
printers[num_printers++] = current;
}
if (!haveDefault && (returned > 0))
printers[0]->is_default = TRUE;
GlobalFree(prninfo);
return printers;
}