f



Change default printer

I have an application I'm working on in Delphi 5 (Win 2k) and I want
to create a report which I can fax to various recipients. Creating the
report is easy (I'm using Quick Reports), but I want to change the
default printer driver and force the system to use a specific one
(which is a fax driver), which will not be the Windows default
printer. It should however, be set up the same on each PC so I will
initially want to aim for that (and handle errors later).

The problem is forcing it to use a specific printer driver. There
aren't any obvious options in Quick Reports, so I can't set it as
easily as I wanted.

The one I want to use is linked to our Castell Fax Server so I can get
that to generate the fax from the print job.

Any ideas would be welcome.

Thanks
0
ryanofford
12/17/2003 4:25:04 PM
comp.lang.pascal.delphi.misc 5769 articles. 1 followers. miniFAQ (1) is leader. Post Follow

3 Replies
483 Views

Similar Articles

[PageSpeed] 28

"Ryan" <ryanofford@hotmail.com> wrote in message
news:7802b79d.0312170825.540c784@posting.google.com...
> I have an application I'm working on in Delphi 5 (Win 2k) and I want
> to create a report which I can fax to various recipients. Creating the
> report is easy (I'm using Quick Reports), but I want to change the
> default printer driver and force the system to use a specific one
> (which is a fax driver), which will not be the Windows default
> printer. It should however, be set up the same on each PC so I will
> initially want to aim for that (and handle errors later).
>
> The problem is forcing it to use a specific printer driver. There
> aren't any obvious options in Quick Reports, so I can't set it as
> easily as I wanted.
>
> The one I want to use is linked to our Castell Fax Server so I can get
> that to generate the fax from the print job.
>
> Any ideas would be welcome.
>
> Thanks

Check Help - Tprinter.setPrinter
Tom


0
Tom
12/17/2003 5:44:49 PM
Managed to find the code I needed on QUSoft.com and it works
perfectly. So have adapted this to find the current printer, swap to
the one I want, and then swap back to the original one afterwards.

Posting here in case it's of help to anyone else looking for this
solution at some point later.

Setting the Default Printer from code
=====================================

If you need to use a different printer than the default you
may have to change the default printer programmatically, run
your report and then change it back. Here is some sample code to do
this:

procedure SetDefaultPrinter(PrinterName: String);
var
   I: Integer;
   Device : PChar;
   Driver : Pchar;
   Port   : Pchar;
   HdeviceMode: Thandle;
   aPrinter : TPrinter;
begin
  Printer.PrinterIndex := -1;
  getmem( device, 255);
  getmem( Driver, 255);
  getmem( Port, 255);                                           
  aPrinter := TPrinter.create;
  for I := 0 to Printer.printers.Count-1 do
  begin
    if Printer.printers[i] = PrinterName then
    begin
      aprinter.printerindex := i;
      aPrinter.getprinter( device, driver, port, HdeviceMode);
      StrCat(Device, ',');
      StrCat(Device, Driver );
      StrCat(Device, Port );
      WriteProfileString('windows', 'device', Device );
      StrCopy( Device, 'windows' );
      SendMessage(HWND_BROADCAST, WM_WININICHANGE, 0,
Longint(@Device));
   end;
  end;
  freemem( device, 255);
  freemem( Driver, 255);
  freemem( Port, 255);
  aPrinter.free;
end;
0
ryanofford
12/18/2003 1:15:50 PM
"Ryan" <ryanofford@hotmail.com> wrote in message
news:7802b79d.0312180515.642f8969@posting.google.com...
> Managed to find the code I needed on QUSoft.com and it works
> perfectly. So have adapted this to find the current printer, swap to
> the one I want, and then swap back to the original one afterwards.

You should also be able to use

    Printer.PrinterIndex := Printer.Printers.IndexOf (PrinterName);


0
Bruce
12/18/2003 3:23:33 PM
Reply:

Similar Artilces:

After the default printer has been changed by code in Access 2003, the application still directs a report to the former default printer.
Could someone please help? I am using the 'defaultprt.zip' tool provided by Ken Getz to change the default printer via VBA code (code below). My problem is that once the default printer has been changed, Access 2003 still directs the report to the former default printer. Access 2003 picks up the new default printer setting only after I have reopened the application. I have checked the default printer setting in the OS control panel and the code works well. This problem also occurs when an Access 2003 application is open and one changes the default printer manually in the control panel ...

change default printer to network printer
Guys, I need help . I am using vb5. I am try to print one report @ two different location. 1) is default and 2) is on network. I am trying to set network printer as default for second time. The program was written in win98 and it is working good. but we are try to update all the computers for XP. Thanks for help Bharat Parekh *** Sent via Developersdex http://www.developersdex.com *** You can grab my printer swtich code here: http://www.members.shaw.ca/AlbertKallal/msaccess/msaccess.html -- Albert D. Kallal (Access MVP) Edmonton, Alberta Canada pleaseNOOSpamKallal@msn.com htt...

change printer in report pro to non default printer
Whenever i change my printer to a not default, it will at the end print to the default. Am i missing something? oReport := RpReport{ oSELF:owner,m->reportpath+ 'labels.rpt',,{{'labels',ofile, , ,,,nil}}} oReport:Connect2Source() oprinter:= PtrDevice{oself, oReport} if !oprinter:SetPrinterByName(clabelprinter) return false endif if oprinter:ShowPrintDlg() // label printer is selected here endif ..... oReport:Print(cJobName,cPrint2Filename,cCaption,CMessage) // prints to default printer?? Thx, Geert oReport := ...

change default printer
Hello! i amn trying to add a Visuail basic 6 code to an excisting code that has the purpose to change the current default printer to another printer by name and then after the printer to change back to the old default printer again... Anyone knows how to do this easy?? http://vbnet.mvps.org/code/system/defaultprinter.htm http://vbnet.mvps.org/code/system/setdefaultprinter.htm -- Randy Birch MS MVP Visual Basic http://vbnet.mvps.org/ ---------------------------------------------------------------------------- Read. Decide. Sign the petition to Microsoft. http://classicvb.org/petition...

default printer changing
I have XP and 2 printers with the laserjet set as default but can change when I want to an all-in-one office jet to use if I wish. Suddenly, whenever I re-start the computer my default printer changes to the officejet all-in-one fax. How do I prevent this from happening? Thanks On Nov 15, 4:44=A0am, DMD31842 <ddavids...@verizon.net> wrote: > I have XP and 2 printers with the laserjet set as default but can > change when I want to an all-in-one office jet to use if I wish. > Suddenly, whenever I re-start the computer my default printer changes > to the officejet all-...

Change Default-Printer
Hi, I need a way, to change the Windows-Default-Printer by a Program without any action of the User. It is in a setup-program for an application that must use a special printer-driver. Thanks for the Help Matthias "Maxwell" <matthias.eiser@web.de> wrote in message news:2sldqnF1lra05U1@uni-berlin.de... > Hi, > I need a way, to change the Windows-Default-Printer by a Program without any > action of the User. It is in a setup-program for an application that must > use a special printer-driver. http://support.microsoft.com/default.aspx?scid=k...

how to change the change defaults
hi friends, it might be a stupid question to state. but i really need to know while programming, to change the defaults like changing the engineering notation of a real quantity i.e. fraction values or change the fix parameters to denote real value if our calculations involve the values as low as 0.000000001 and as high as 10000000. thanks hemu bisht ...

Change default printer port
I'm sending print jobs to a remote network. The firewall on the remote network maps ports to specific IP addresses. The trouble is, I have two printers that use the same default port (9100). I can change the port on the printer itself but how can I change the port in Unix to match? lmccluskey@bcdi.com (Larry) writes: > >I'm sending print jobs to a remote network. The firewall on the remote >network maps ports to specific IP addresses. The trouble is, I have >two printers that use the same default port (9100). I can change the >port on the printer itself but how can I ch...

Change Default Printer Setting?
I'd like to change the default printer setting "Print Quality" from Normal to Fast Draft. How is this done? Option-Select'ing the menu choice doesn't seem to work. Or is it different for every printer driver? In other words, should I be calling HP? Stu (who hopes you are all well) NP: When It Was Now by Weather Report G'day Stu, A bit more info (type of Mac, what OS (9? 10.2.x? 10.3.x? 10.4?) and what type of HP printer would help generate more help ... But still, I have a G3 iMac running 10.3.9, with an HP psc 1210. Nothing I could do would change the def...

Problem changing default printer
I have to add one or more printers to to the profile of a user logged onto a remote computer. I've done this by updating the HKCU registry settings. This part works fine. I also have installed a utility on the remote computer that the user will execute to change the default printer to one of the newly installed printers. This is where I encounter problems. When the use executes the utility, it will NOT change the default printer. But if the user restarts the computer and executes the utility, the default printer will be successfully changed. So, my question is why the compu...

How to change default printer from frame
I want to use F_ApiSilentPrintDoc to print a book. In Windows I cannot specify the printer name in the properties of the document or book. It always uses the default printer. How can I modify the default printer from my code ? Tks ...

how to change the change defaults #2
hi friends, it might be a stupid question to state. but i really need to know while programming, to change the defaults like changing the engineering notation of a real quantity i.e. fraction values or change the fix parameters to denote real value if our calculations involve the values as low as 0.000000001 and as high as 10000000. thanks hemu bisht ...

How to change default printer in Windows using Perl
Hello. Can someone point me in the right direction on changing my default Windows printer using Perl? TIA "Domenico Discepola" <domenico_discepola@quadrachemicals.com> wrote in message news:0%SJc.32041$vO1.149777@nnrp1.uunet.ca... > Hello. Can someone point me in the right direction on changing my default > Windows printer using Perl? > Answered my own question: #!perl use strict; use warnings; use diagnostics; use Win32::TieRegistry ( Delimiter=>"/", ArrayValues=>1 ); #Get value of default printer my $def_printer = $Registry->{"HKEY_CU...

Web resources about - Change default printer - comp.lang.pascal.delphi.misc

Credit default swap - Wikipedia, the free encyclopedia
Sovereign credit default swap prices of selected European countries (2010-2011). The left axis is basis points, or 100ths of a percent; a level ...

INFOGRAPHIC: The History Of Facebook's Default Privacy Settings
INFOGRAPHIC: The History Of Facebook's Default Privacy Settings

Secure browsing by default
We now use https by default for all Facebook users. This feature, which we first introduced as an option two years ago , means that your browser ...

北方理財團隊的家園:http://group.hexun.com/m132312/default.html外汇交易员芬芳fenfang恭候您! - 芬芳FENFANG - 和讯博客
北方理財團隊的家園:http://group.hexun.com/m132312/default.html外汇交易员芬芳fenfang恭候您! - 芬芳FENFANG - 芬芳FENFANG的博客 - 和讯博客

Tab applications for musicians look to innovate after Facebook removes default landing function
... landing tabs. Most page applications have experienced significant drops in daily and monthly active users now that Facebook removed the default ...


Google AdWords Regional Targeting (Default for US) - Flickr - Photo Sharing!
Explore Tamar Weinberg's photos on Flickr. Tamar Weinberg has uploaded 4087 photos to Flickr.

[3DS] Bravely Default: AR (English Subs) - YouTube
Turn on Annotations For Subs -May redo them as real CC subtitles- ★EDIT☆ ☆上から撮影した映像はこちら ★The top view video is here http://www.youtube.com/w ...

Default password leaves tens of thousands of Optus cable subscribers at risk
When Alex* found flaw in his cable modem that allowed anyone to receive and make calls using his number, his jaw dropped.

Google paid Apple $1 billion in 2014 to keep it the default search engine on iOS devices
... paid Apple $1 billion in 2014 as part of its ongoing deal to be the main search provider—as in the one that resides in the search bar by default—on ...

Resources last updated: 2/13/2016 12:13:14 AM