Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QuickReport throws "There Is No Default Printer Currently Selected" Exception

I have created a Delphi Service which prints TQuickReports. Everything works fine if compiled and run as a Windows Application. But when converted to operate as a service trying to create a form containing a TQuickRep component throws the exception.

This service runs fine on many other boxes but not this one in particular. Here are some details:

  • Using QuickReport version 4.07
  • Box is a Windows Server 2008 operating system.
  • Using Delphi 2007
  • Printer.Printers.Count is returning a positive value. In fact I can list out all of the printers.
  • I have tried running the service both using Local System Account and Logged on as an Admin.
like image 958
M Schenkel Avatar asked Dec 03 '22 05:12

M Schenkel


2 Answers

Is there a default printer set up in session 0? Remember that under Vista / Server 2008 / Windows 7, services run in a separate session. Whether or not the logged-in user has a default printer set is not relevant - it's a per-session setting and doesn't affect session 0.

Can you rewrite the code to gracefully handle that exception and pick a printer to use?

like image 160
Mihai Limbășan Avatar answered Mar 17 '23 06:03

Mihai Limbășan


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

Make sure you have a local printer selected.

like image 38
Niek H. Avatar answered Mar 17 '23 06:03

Niek H.