Home General
New Blog Posts: Merging Reports - Part 1 and Part 2

Default Printer - Windows Server 2016 (RDP)

edited February 2017 in General
Hi,

We are using Report Builder Professional 17.02 Build 149 for report
generation.

We have found that on Windows Server 2016 over RDP the default printer
is incorrectly selected when printing a report - the default appears to
be the first listed printer rather than the default redirected printer
(as with previous versions of Windows Server).

The problem appears to be related to the use of getProfileString to
retrieve the default printer - this appears to no longer work correctly
in Windows Server 2016 when using printer redirection as the registry
key/value mappings have changed.

I notice that the logic for the getDefaultPrinter api call is already
included (and commented out) in the code base.

Would it be possible to build a new release that uses getDefaultPrinter?

Thanks and regards,
David

Comments

  • edited February 2017
    Hi David,

    RB caches the list of available printers and default printer.

    Try adding code to refresh the global printer list.

    uses
    ppPrintr;

    ppPrinters.Refresh;

    // can test it like this..
    procedure TForm1.Button1Click(Sender: TObject);
    begin
    ppPrinters.Refresh;
    ShowMessage(ppPrinters.DefaultPrinterName);

    end;







    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited February 2017
    Nard Moseley (Digital Metaphors) wrote:

    Hi Nard,

    Thanks for the reply. I'm afraid that's not the problem. Tested with the
    following code (Delphi Berlin):


    function GetDefaultPrinter(Buffer: PChar; var BufferSize: DWord): BOOL;
    stdcall;
    external 'winspool.drv' name 'GetDefaultPrinterW'; //
    GetDefaultPrinterA on pre-Unicode Delphi versions

    procedure TForm1.Button1Click(Sender: TObject);
    var
    BuffSize: DWord;
    Buff: string;
    begin
    //get ppprinters default
    memo1.Lines.Add('Current Default (ppprinters): ' +
    ppprinters.DefaultPrinterName);

    //refresh and try again
    ppprinters.Refresh;
    memo1.Lines.Add('Default after refresh (ppprinters): ' +
    ppprinters.DefaultPrinterName);

    //try with delphi printers unit
    printer.PrinterIndex := -1;
    memo1.Lines.Add('Default using printers unit (Delphi Berlin): ' +
    printer.Printers.Strings[Printer.PrinterIndex]);

    //try using GetDefaultPrinter api call
    GetDefaultPrinter(nil, BuffSize);
    SetLength(Buff, BuffSize);
    if GetDefaultPrinter(PChar(Buff), BuffSize) then begin
    memo1.Lines.Add('Default using getDefaultPrinterW: ' + buff);
    end else begin
    memo1.Lines.Add('Default using getDefaultPrinterW: failed');
    end;

    end;


    This results in the following output on Windows Server 2016:

    Current Default (ppprinters): Microsoft Print to PDF
    Default after refresh (ppprinters): Microsoft Print to PDF
    Default using printers unit (Delphi Berlin): Support Printer (redirected
    442)
    Default using getDefaultPrinterW: Support Printer (redirected 442)

    On Windows Server 2008 R2 we get the following:

    Current Default (ppprinters): Support Printer (redirected 125)
    Default after refresh (ppprinters): Support Printer (redirected 125)
    Default using printers unit (Delphi Berlin): Support Printer (redirected
    125)
    Default using getDefaultPrinterW: Support Printer (redirected 125)

    And on Windows Server 2012 R2:

    Current Default (ppprinters): Support Printer (redirected 3549)
    Default after refresh (ppprinters): Support Printer (redirected 3549)
    Default using printers unit (Delphi Berlin): Support Printer (redirected
    3549)
    Default using getDefaultPrinterW: Support Printer (redirected 3549)


    I hope this highlights that problem only occurs with Windows 2016 and is
    a result of a change to how redirected printers are stored in the
    registry. As far as I can tell there is no workaround for getProfileString.


    Thanks and regards,
    David
  • edited February 2017
    Hi Nard,

    Is there any feedback regarding this issue? We unfortunately deployed a
    Windows 2016 Server about a month ago and have been struggling with the
    default printer issue ever since.

    I look forward to hearing from you.

    Kind regards,
    David
  • edited February 2017
    Hi David,

    I'm working on a patch for RB 18 to try to address this.

    Please send license details to support@

    company:
    contact:
    email:
    serial number:



    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
  • edited March 2017
    Hi,

    We have the same problem with wrong default printer in Server 2016, using
    RB17.

    Is this problem fixed?

    John

    På Wed, 08 Feb 2017 22:38:24 +0100, skrev Nard Moseley (Digital Metaphors)
  • edited March 2017
    Hi John,

    There is a patch available for RB 18.


    Best regards,

    -
    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com

    Best regards,

    Nard Moseley
    Digital Metaphors
    www.digital-metaphors.com
This discussion has been closed.