daniel_c
asked on
Set default printer
How to set available printers in Windows to default from Delphi?
Euhm, changing the PrinterIndex property?
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 .
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 .
You can write to register
[HKEY_LOCAL_MACHINE\Config \0001\Syst em\Current ControlSet \Control\P rint\Print ers]
"Default"="xxxxx"
[HKEY_CURRENT_CONFIG\Syste m\CurrentC ontrolSet\ Control\Pr int\Printe rs]
"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
[HKEY_LOCAL_MACHINE\Config
"Default"="xxxxx"
[HKEY_CURRENT_CONFIG\Syste
"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
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(Prin ter.Printe rs);
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
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(Prin
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
ASKER
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?
for instance, HP Laser 1100 is 1, Epson LQ 1070 is 2, and so on?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks Neil!
Thanks Tom!
I wish I can give point to both of you!
Thanks Tom!
I wish I can give point to both of you!