Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Set default printer

Posted on 2000-02-17
7
Medium Priority
?
1,107 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
ID: 2530468
Euhm, changing the PrinterIndex property?
0
 
LVL 8

Expert Comment

by:ZifNab
ID: 2530469
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
ID: 2530508
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 5

Expert Comment

by:TheNeil
ID: 2530677
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
ID: 2530738
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 80 total points
ID: 2530795
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
ID: 2534034
Thanks Neil!
Thanks Tom!

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

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
Please read the paragraph below before following the instructions in the video — there are important caveats in the paragraph that I did not mention in the video. If your PaperPort 12 or PaperPort 14 is failing to start, or crashing, or hanging, …
Look below the covers at a subform control , and the form that is inside it. Explore properties and see how easy it is to aggregate, get statistics, and synchronize results for your data. A Microsoft Access subform is used to show relevant calcul…

886 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