Set default printer

How to set available printers in Windows to default from Delphi?
Who is Participating?
TheNeilConnect With a Mentor Commented:
Depends HOW you got the printer names into the ComboBox. If you just did


Then you can get the index directly. e.g.

NewIndex := ComboBox1.ItemsIndex;

If you sorted the values or did anything to them then you need to search through the list of printers (Printer.Printers), and compare the selected printer name with each item.

NewIndex := -1;
FOR i := 0 TO (Printer.Printers.Count - 1)
  IF UpperCase(ComboBox1.Text) = UpperCase(Printer.Printers[i])
    NewIndex := i;

The Neil
Euhm, changing the PrinterIndex property?

if (MessageDlg('Do you want to use the default printer',
                               mtInformation, mbYesNoCancel,0)=idYes) then
                                 Printer.PrinterIndex := -1;

 To switch another printer , set the aproprieted index to it .
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

You can write to register



Set xxxxx to your  printer. but select only the installed printer’s to default.
You can test if a printer is install before you set it to default
just read the key’s under Printers in register.

If it is in a network with a lot of computers you can do like I did.

I dump all  Mac address to a file and filed with default ,ComputerName & printer..

I make I program that compare MAC from computer and file.
And then set the value’s to register and reboot the computer if it is wrong value’s

So now wen I ghost all 300 computer I don’t need to go to all to set Name and default printer.
The user that login first set the right value
That won't set the default WINDOWS printer, only the printer currently being used in the Delphi app. God knows how you actually modify THAT

To expand on what ZifNab has said, you can get the complete list of printer NAMES by accessing the Printers property of the TPrinter object.


It's then just a case of setting the PrinterIndex property to the item selected by the user (which is what ZifNab said)

The Neil
daniel_cAuthor Commented:
If I use Printer Index, whereas, I use combo box which contains the available printers, how do I know that...
for instance, HP Laser 1100 is 1, Epson LQ 1070 is 2, and so on?
daniel_cAuthor Commented:
Thanks Neil!
Thanks Tom!

I wish I can give point to both of you!
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.