Workaround for bug 1732 created by Eric Cole.
To get around the problem related to wrong default printer when connected to Windows Server 2016, or Windows 10, through either RDP or Citrix, you can try this.
It is based on windows api function GetDefaultPrinter and it can be placed in application open event.
Private Function Long GetDefaultPrinterW ( Ref String pszPrinter, Ref Ulong size ) library "winspool.drv" Alias for "GetDefaultPrinterW"
String ls_printer
ULong ul_prnbuf
SetNull ( ls_printer )
GetDefaultPrinterW ( ls_printer, ul_prnbuf ) //Returns nbr. of characters needed to hold the printername.
If ul_prnbuf > 0 Then
ls_printer = Space ( ul_prnbuf )
GetDefaultPrinterW ( ls_printer, ul_prnbuf )
End If
//If ls_printer holds a value then use PB PrintSetPrinter to set default application printer
If ls_printer <> "" Then
PrintSetPrinter ( ls_printer )
End If
/*
Before Windows 10/Win. Server 2016 you would find the default printer in reg. key :
HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows:Device
It did not matter if you were logged in through RDP/Citrix or directly on the machine.
Now, if you are connected through RDP/Citrix the default printer is stored in this reg. key :
HKCU\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\PART_OF_SID\Device
*/
TEN
Running PB 2017 R3 build 1858 on Windows 10 build 1803 connecting to a Windows Server 2016/Windows 10 through RDP/Citrix and running PrintSetup() will return the (latest) local default printer on the server as the selected entry in the list. Not the local default printer on my machine.
It is quite easy to test if you have a locale printer which does not exist on then server.
Regards
TEN
Thanks for the feedback and our sincere apologies for this fix not working 100%!
I will notify our Appeon Support team on this.
Regards .. .Chris