Solved

Change Win31 default printer with Delphi1

Posted on 1997-07-02
3
168 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

[Webinar] Code, Load, and Grow

Managing multiple websites, servers, applications, and security on a daily basis? Join us for a webinar on May 25th to learn how to simplify administration and management of virtual hosts for IT admins, create a secure environment, and deploy code more effectively and frequently.

Question has a verified solution.

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

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…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Exchange organizations may use the Journaling Agent of the Transport Service to archive messages going through Exchange. However, if the Transport Service is integrated with some email content management application (such as an antispam), the admini…

734 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