- Tor-Egil Nygaard
- PowerBuilder
- Friday, 12 October 2018 01:58 PM UTC
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.
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
Find Questions by Tag
Helpful?
If a reply or comment is helpful for you, please don’t hesitate to click the Helpful button. This action is further confirmation of their invaluable contribution to the Appeon Community.