[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

Change Win31 default printer with Delphi1

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
DiogoAssuncao
Asked:
DiogoAssuncao
1 Solution
 
OzBodCommented:
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
 
DiogoAssuncaoAuthor Commented:
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
 
GaborCommented:
Find the SetPrinter(...) API function and the PRINT_INFO_2 structure and it's Attributes field!
0

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now