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

Printer Name Changes in Terminal Services

edited March 2003 in General
Hello All:

We have a Delphi 5 app/RB 6.03 running in terminal services. We store
the name of the printers used by our app in the registry so that the user
does not need to select ther printer themselves. We use dot matrixc printers
for some types of printing and lasers for other types of printing.

We use the printer name to attach to the winspooler.

Under terminal services, the printer name is as follows:
printername\computername\sessionX

Every time the user logs on, the printer name changes because the
session id is changed. Since we store the printer name and use it with a
call to the WIN API, we are getting errors because the printer name has
changed. ( ie Okidata 321\Computer\Session5 vs Okidata
321\Computer\Session2 ).

We need to save the printer name because of user requirements. Any ideas
on a workaround ???

1) When the name is loaded, if it has "Session" in it, do we need to
compare it to the list of current printer names to pick up the current name
???

2) Any other workarounds ???

Thank you.

Neil Huhta

Comments

  • edited March 2003
    Are you using report templates? If so, then use the
    Report.Template.OnLoadEnd event in order to assign the
    Report.PrinterSetup.PrinterName to the current
    PrinterName\MachineName\SessionID from the WinAPI call. This way you don't
    have to save the PrinterName\MachineName\SessionID to the registry but
    rather just always get it dynamically at runtime.

    Cheers,

    Jim Bennett
    Digital Metaphors


  • edited March 2003
    Jim:

    We store the reports in .rtm files. However, we dont use reportbuilder
    to actually print the reports because we print irregular form sizes on dot
    matrix printers ( not supported by printer drivers ).

    We load the .rtm file into a ppReport component, then we parse the draw
    commands, then attach to the winspooler, then issue escape codes to
    precisely control dot matrix printing ( only way to go ).

    We dont want our users to have to specify which printer is for dot
    matrix printing every time they start our application. We want to select it
    once, then use that printer for the specialized dot matrix printing.

    We need the name because we use the OpenPrinter API to attach to the
    winspooler ( only way to go for direct printing ).

    Could I store everything but the \session4, then attach the correct
    session id once the user is logged in ???

    Do you know how to get the current session ID from terminal services ???

    Now that you know more of what we are doing, can you point us in the
    correct direction ???


    Thank you.


    Neil Huhta



  • edited March 2003
    Jim:

    I solved the problem by iterating through the TPrinters list and
    comparing the name less the sessionid. It works great.


    Neil Huhta
This discussion has been closed.