Solved

Change Win31 default printer with Delphi1

Posted on 1997-07-02
3
155 Views
Last Modified: 2011-09-20
How can I change Windows 3.1's default printer using Delhpi 1?
I want to call another application and print a document from my Delphi app, I've no way to select the destination printer , unless I change windows' default printer. I have more than one printer installed (or I can access others, in the LAN)in my system.
0
Comment
Question by:DiogoAssuncao
3 Comments
 

Expert Comment

by:OzBod
ID: 1338071
To switch between printers you can use the TPrinter object. Using the PrinterIndex property you can set the desired printer you want to use. The default printer is -1

You may want to give a list of all the installed printers in a list box for example for the user to select the printer. Below is a code snippet to show you how this may be done.

procedure TForm1.Button1Click(Sender: TObject);

var   MyPrinter : TPrinter;

begin
   MyPrinter := TPrinter.Create;
   ListBox1.Items := MyPrinter.Printers;
end;

procedure TForm1.ListBox1Click(Sender: TObject);

begin
   MyPrinter.PrinterIndex := ListBox1.ItemIndex;
end;

Hopefully this should solve your problem. Alternatively you may wish to look at the PrinterSetupDialog component.

Cheers... Peter
0
 

Author Comment

by:DiogoAssuncao
ID: 1338072
That will solve my problems within Delphi, I will be able to print anything to any printer within my Delphi application.
What I want is to change windows' default printer, so that every
application will print to it if I don't select a specific
printer.
0
 
LVL 1

Accepted Solution

by:
Gabor earned 10 total points
ID: 1338073
Find the SetPrinter(...) API function and the PRINT_INFO_2 structure and it's Attributes field!
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
PDF library for Delphi 2 107
build html 5 client that connect to indy Tidtcpserver 3 357
Print Graphic and Text to Epson TM-T88v 12 188
update joined tables 2 32
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
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…
In this video I am going to show you how to back up and restore Office 365 mailboxes using CodeTwo Backup for Office 365. Learn more about the tool used in this video here: http://www.codetwo.com/backup-for-office-365/ (http://www.codetwo.com/ba…
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

864 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

19 Experts available now in Live!

Get 1:1 Help Now