Solved

Seting default printer

Posted on 2000-04-14
7
151 Views
Last Modified: 2010-04-04
Hello,
 Here is my question : How can i set dynamicaly the Window's default printer ?

Here is the situation : My customer has 2 printers : 1 Epson (Dot-Matrix), and 1 Cannon (Ink jet). He needs both. I plugged an Hardware switch, but now i need something like an software switch.

Thanks for all ideas.

Note : points will be upgraded up to 500 for an answer today.
0
Comment
Question by:helpme020897
7 Comments
 

Author Comment

by:helpme020897
ID: 2715690
Second note : Programs using printers are not mine...   so i can do nothing inside those programms...

         HelpMe
0
 
LVL 9

Expert Comment

by:ITugay
ID: 2715773
Try to search PAQ in this topic area "set default printer", there are good answers avalable for 1 or 3 points only.
-----
Igor.
0
 
LVL 4

Expert Comment

by:Radler
ID: 2716053
A software switch is a expensive product.
To the future and analising the local resources buy a USB printer or a net ( Expensive too, but with some advantages ).

T++, Radler.
0
Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

 
LVL 17

Accepted Solution

by:
inthe earned 500 total points
ID: 2716538
Uses Printers;

var Printlist:TStringlist;
    i:integer;
begin
   PrintList:=Tstringlist.create;
   PrintList.AddStrings(Printer.Printers);
   For i:=0 to Printlist.Count-1 do
begin
     if uppercase(Printlist.Strings[i])='STYLUS COLOR 600' then
     begin
        Printer.PrinterIndex:=i;
        exit;    
     end;
end;
   showmessage('Error finding printers');
end;




or:

you can also change the default one like so:



var
Device : array[0..255] of char;
Driver : array[0..255] of char;
Port : array[0..255] of char;
hDeviceMode: THandle;
begin
Printer.PrinterIndex := 1; //or 2 etc
Printer.GetPrinter(Device, Driver, Port, hDeviceMode);
StrCat( Device, ',');
StrCat( Device, Driver );
StrCat( Device, ',');
StrCat( Device, Port );
WriteProfileString( 'windows', 'device', Device );
StrCopy( Device, 'windows' );
SendMessage( HWND_BROADCAST, WM_WININICHANGE, 0, longint( @Device ));
0
 
LVL 4

Expert Comment

by:mhervais
ID: 2722743
listening
0
 

Author Comment

by:helpme020897
ID: 2723645
Adjusted points from 200 to 500
0
 

Author Comment

by:helpme020897
ID: 2723646
thanks a lot
    HelpME
0

Featured Post

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Newbie Thread Programming 1 151
Delphi cmd execution 6 60
indy Tmemory stream non latin charcter issue 2 110
When i run adoquery my application freezes 26 166
Objective: - This article will help user in how to convert their numeric value become words. How to use 1. You can copy this code in your Unit as function 2. than you can perform your function by type this code The Code   (CODE) The Im…
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…
This Micro Tutorial will teach you how to censor certain areas of your screen. The example in this video will show a little boy's face being blurred. This will be demonstrated using Adobe Premiere Pro CS6.
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…

776 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