1

I created a very simple ISAPI DLL with the following code on the default handler:

procedure TWebModule1.WebModule1DefaultHandlerAction(Sender: TObject;
  Request: TWebRequest; Response: TWebResponse; var Handled: Boolean);
var
  DevHandle : THandle;
begin
  Printer.PrinterIndex := 0;
  DevHandle := Printer.Handle;
end;

The second line always fails with "Printer Selected is not Valid." I originally thought this might be a rights issue, but have tried identities with adequate rights. Additionally, the Printer class does return the correct list of printers/drivers matching those installed on my machine.

Is there a way around this error so the default printer can be selected and I can retrieve the printer handle?

Jeff Cope
  • 781
  • 2
  • 7
  • 15
  • IIS/ISAPI do not run under a standard user account. Are you sure that the account use has printer access? – fpiette Apr 07 '21 at 14:47
  • I tried using a specific user account with local admin rights assigned to the pool, but run into the same issue. Same with LocalSystem account. – Jeff Cope Apr 07 '21 at 16:29

1 Answers1

1

I am not sure it is safe to print from ISAPI dll , it may hang and several client can try to access at the same time.

what i have done : ISAPI request write on local database what it wanted to print , then display an animation at client side while it waits for an external software to finish the job.

not sure it helps ..

Eski
  • 97
  • 3
  • In this instance I'm using ace reporter to generate a report file with a unique name and it is not actually going to the printer. However, engrained in ace reporter are lots of accesses to the default printer even if the report output type is set to file. – Jeff Cope Apr 07 '21 at 16:30