Solved

Set default printer

Posted on 2000-02-17
7
1,076 Views
Last Modified: 2008-03-04
How to set available printers in Windows to default from Delphi?
0
Comment
Question by:daniel_c
  • 2
  • 2
  • 2
  • +1
7 Comments
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
Euhm, changing the PrinterIndex property?
0
 
LVL 8

Expert Comment

by:ZifNab
Comment Utility
eg

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 .
0
 
LVL 6

Expert Comment

by:Dark_King
Comment Utility
You can write to register



[HKEY_LOCAL_MACHINE\Config\0001\System\CurrentControlSet\Control\Print\Printers]
"Default"="xxxxx"



[HKEY_CURRENT_CONFIG\System\CurrentControlSet\Control\Print\Printers]
"Default"="xxxxx"

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
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 5

Expert Comment

by:TheNeil
Comment Utility
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.

ListBox1.Itesm.Assign(Printer.Printers);

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
0
 
LVL 7

Author Comment

by:daniel_c
Comment Utility
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?
0
 
LVL 5

Accepted Solution

by:
TheNeil earned 20 total points
Comment Utility
Depends HOW you got the printer names into the ComboBox. If you just did

ComboBox1.Items.Assign(Printer.Printers);

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.
e.g.

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

The Neil
0
 
LVL 7

Author Comment

by:daniel_c
Comment Utility
Thanks Neil!
Thanks Tom!

I wish I can give point to both of you!
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
In my programming career I have only very rarely run into situations where operator overloading would be of any use in my work.  Normally those situations involved math with either overly large numbers (hundreds of thousands of digits or accuracy re…
Internet Business Fax to Email Made Easy - With eFax Corporate (http://www.enterprise.efax.com), you'll receive a dedicated online fax number, which is used the same way as a typical analog fax number. You'll receive secure faxes in your email, fr…
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now