Link to home
Start Free TrialLog in
Avatar of sile
sile

asked on

Detecting default printer !

How can I detect if there is a default printer selected ?
I don't need to know if there is a printer installed just if it there is a DEFAULT printer selected.
ASKER CERTIFIED SOLUTION
Avatar of sperling
sperling

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of sile
sile

ASKER

Now I have tried the code but it doesn't work if there is no printer installed ... In this case my app. terminates and I get an error message saying No default printer currently sellected ?
Can you make it work in this case ?

Hmmm... Try this one.


function DefaultPrinter : STRING;
begin
  if (Printer=nil) or (Printer.Printers=nil)
  or (Printer.Printers.Count = 0)
  then begin
    Result := ''
  end else begin
    try
      Printer.PrinterIndex := -1;
      Result := Printer.Printers[Printer.PrinterIndex];
    except
      on Exception do Result := '';
    end;
  end;
end;


Regards,

Erik.
Avatar of sile

ASKER

Ok THANX it works now.
Bought this Q...