Date: Sun, 11 Aug 2002 11:59:08 +0200 Newsgroups: borland.public.delphi.winapi Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Newsreader: Virtual Access by Atlantic Coast PLC, http://www.atlantic-coast.com/va Organization: TeamB Message-ID: Subject: Re: Standard printer From: "Peter Below (TeamB)" <100113.1101@compuXXserve.com> Reply-To: 100113.1101@compuXXserve.com References: <3D5618B3.7E7B9328@come-design.de> NNTP-Posting-Host: 172.185.159.80 X-Trace: dnews 1029059663 172.185.159.80 (11 Aug 2002 02:54:23 -0700) Lines: 37 Path: dnews!not-for-mail Xref: dnews borland.public.delphi.winapi:172761 In article <3D5618B3.7E7B9328@come-design.de>, Dr. Oswald Wagner wrote: > in a simple application I want to print to a special label printer. If > set to "standard printer" everything works well. But if another printer > is set as standard and I only change the active printer within my app, I > get a Blue Screen under Win2k (!!) when I try printing. The company, > which wrote the printer driver, doesn't help charge-free. > How can I change the standard printer with D6? var Device : array[0..255] of char; Driver : array[0..255] of char; Port : array[0..255] of char; hDeviceMode: THandle; begin Printer.PrinterIndex := ....; // select printer to make default 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 )); The last sendmessage call in this old sample should better be changed to a SendMessageTimeout to avoid problems if some threads owning windows on the system are blocked. -- Peter Below (TeamB)