Solved

Change Win31 default printer with Delphi1

Posted on 1997-07-02
3
151 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

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
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…
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…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

757 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

23 Experts available now in Live!

Get 1:1 Help Now