Solved

Seting default printer

Posted on 2000-04-14
7
153 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
Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

 
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

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

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…
Have you ever had your Delphi form/application just hanging while waiting for data to load? This is the article to read if you want to learn some things about adding threads for data loading in the background. First, I'll setup a general applica…
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…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

828 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