Solved

Change Win31 default printer with Delphi1

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Suggested Solutions

This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…
Finds all prime numbers in a range requested and places them in a public primes() array. I've demostrated a template size of 30 (2 * 3 * 5) but larger templates can be built such 210  (2 * 3 * 5 * 7) or 2310  (2 * 3 * 5 * 7 * 11). The larger templa…

770 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