From 422b6849573d0c79e7dd37b579c8485ed670a007 Mon Sep 17 00:00:00 2001 From: Armin Novak Date: Mon, 15 Nov 2021 14:47:54 +0100 Subject: [PATCH] Ensure default printer for windows backend. --- channels/printer/client/win/printer_win.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/channels/printer/client/win/printer_win.c b/channels/printer/client/win/printer_win.c index 116664bd6..2cc99cf32 100644 --- a/channels/printer/client/win/printer_win.c +++ b/channels/printer/client/win/printer_win.c @@ -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; }