Solved

Seting default printer

Posted on 2000-04-14
7
150 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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Simple Delphi Question 9 83
Delphi - replicating a form 8 65
oracle global variables 4 63
Magic Software info 18 125
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
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…
Windows 10 is mostly good. However the one thing that annoys me is how many clicks you have to do to dial a VPN connection. You have to go to settings from the start menu, (2 clicks), Network and Internet (1 click), Click VPN (another click) then fi…
This is used to tweak the memory usage for your computer, it is used for servers more so than workstations but just be careful editing registry settings as it may cause irreversible results. I hold no responsibility for anything you do to the regist…

867 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now