QuickReport throws "No printer selected by default" Exception

I created a Delphi service that prints TQuickReports. Everything works fine if compiled and run as a Windows application. But when converting to work as a service trying to create a form containing the TQuickRep component, it throws an exception.

This service works great in many other blocks, but not in particular. Here are a few details:

  • Using QuickReport version 4.07
  • Box is the Windows Server 2008 operating system.
  • Using Delphi 2007
  • Printer.Printers.Count returns a positive value. In fact, I can list all printers.
  • I tried to start the service using both the local system account and login privileges.
+3
source share
8 answers

You can solve this problem by creating a new dword UserSelectedDefault with a value: 1 in HKEY_CURRENT_USER \ Software \ Microsoft \ Windows NT \ CurrentVersion \ Windows \ SessionDefaultDevices \ Session_ID

Make sure the local printer is selected.

+3
source

Is the default printer installed in session 0? Remember that in Vista / Server 2008 / Windows 7 services start in a separate session. Regardless of whether the user logged in to the system has the default set of printers, it does not matter - he is configured for the session and does not affect session 0.

, ?

+5

. Windows, , .

TQuickRep.PrinterSettings.PrinterIndex, . TQuickRep.Print, .

+2

. , , ( , ). , โ€‹โ€‹ "NetworkService" . Windows:

, , NT AUTHORITY\NetworkService

+2

. TS, Citrix Powerfuse 9. Powerfuse , . Delphi/QReport

printserver powerfuse ( , ), .

+1

Delphi (5). (Printers.pas):

if TPrinterDevice(Objects[I]).Device = Device then
begin
   with TPrinterDevice(Objects[I]) do
      SetPrinter(PChar(Device), PChar(Driver), PChar(Port), 0);
   Exit;
end;

: lowercase(TPrinterDevice(Objects[I]).Device) = lowercase(Device) .

+1

2008, , :

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\SessionDefaultDevices\Session_ID 

HKEY_CURRENT_USER\Software\Microsoft\Windows NT\CurrentVersion\Windows\
0

: ( ) Delphi QuickReport, , ( ).

  • QuickReport TQRPrinter.Init, printer.printers.count ,
  • shortly after booting the system, the printer.printers.countnumber of printers
  • but itโ€™s tqrprinter.intalready completed, therefore it TQRPrinter.FPrinterOKโ€™s false,
  • You will see this error when you try to open QuickReport.

The solution for me was to wait for the printers to load before starting the application (in citrix and the terminal server). I solved this in two ways: either overwriting tqrprinteror delaying dpr.

0
source

Source: https://habr.com/ru/post/1739877/


All Articles