Uniface User Forum

 View Only
  • 1.  getting default printer from registry

    Posted 05-11-2021 07:53

    Hello

    Im'using this instruction for getting the default printer

    pDefaultPrinter = $setting("", "HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device", "REGDATA")

    The user  connect in TSE without the "local resources"  setup for printer

    I just implement the connexion with  this option  and my problem  is that the $settings returns me the name of

    printer wich is in use when this option is not set up 

    instead of the printer name I intend to get :   HPxxxx (redirection of x)

    (I hope this is clear)




  • 2.  RE: getting default printer from registry

    PARTNER
    Posted 05-11-2021 08:58

    A google indicates there may be another registry setting for terminal services session default printers. 


    The registry key used for local or network printers is:

    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\Device

    The registry key used for redirect printers is:

    HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\ "session" \Device


    I think you can get the 'session' part of this by looking at the environment variable 'sessionname' (using $setting?) 

    Regards, 

    Iain



  • 3.  RE: getting default printer from registry

    Posted 05-11-2021 11:35

    It looks like this key is in windows server 2012, not with 2016 and present again in 2019

    currently I need it in 2012 and 2019 (lucky)

    so how do I use $setting to get the session name ?

    I'm using  Query Session / Qwinsta to get the session name  and it gives me :

    rdp-tcp#128   and in the register I got   : S-1-5-5-0-2612842709