🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #12586

Re: Windows Printers

#12586
From: John Scott
Date: Fri, 28 Nov 2003 16:07
83 lines
3620 bytes
Hi. I have a similar problem. I am using the Printer() object to print cards
that are to be mailed out. My client is getting an HP printer with a duplex
capability. Thus I need to send the PCL command Esc&a2G to make it select
the second side of the card.
How can I mix the WritePrinter() functions with the Printer() ones? I tried
WritePrinter(Printer()->Handle, ...) but that did not work, there was no
error but nothing was printed.
If I can't mix them then how do I control where data is printed if I use the
WritePrinter() method?

John Scott


"Peter Rees" <peter@NOOSPAMMrees.co.nz> wrote in message
news:3fbd8132$1@newsgroups.borland.com...
> Albert
>
> > In Windows 95, 98 & Me, I can send raw text directly to a Generic/Text
> Only
> > Windows printer using TPrinter but this doesn't work in XP & 2000.  Does
> > anyone know of a solution to this?
> >
> > If I can't use TPrinter to print, does anyone know how to find out the
> port
> > name from a Windows printer?  I tried TPrinter::GetPrinter() but I got
> junk
> > except for ADevice.  I also tried GetPrinter() but I just got blank
> strings
> > for the strings in PRINTER_INFO_2.
>
> You can print to a printer on any version of windows in RAW mode as below
> (not tested). Note however that not all printers support RAW mode,
> particularly the really cheap inkjets.
>
> Peter
>
>
> #define BIG_BUFFER (1024*32)
>
>   int PrintFileRaw(char *cPrinterName, char *cFileName)
> {
>  int rVal = -1;
>  char bigBuffer[BUG_BUFFER];
>  HANDLE  hPrinter, hFile ;
>   DOC_INFO_1 DocInfo ;
>   DWORD nRead, nWritten, rVal = -1 ;
>     if ( OpenPrinter(cPrinterName, &hPrinter, NULL) != 0 ) {
>         DocInfo.pDocName = cFileName ;
>       DocInfo.pOutputFile = NULL ;
>       DocInfo.pDatatype = "RAW" ;
>       if ( StartDocPrinter(hPrinter,1,(char *) &DocInfo) != 0 ) {
>         if ( StartPagePrinter(hPrinter) != 0 ) {
>           hFile =
>
CreateFile(cFileName,GENERIC_READ,0,NULL,OPEN_EXISTING,FILE_ATTRIBUTE_NORMAL
> ,NULL)   ;
>           if (hFile != INVALID_HANDLE_VALUE ) {
>             while (ReadFile(hFile, printBuffer, BIG_BUFFER, &nRead, NULL)
&&
> (nRead > 0))
>               WritePrinter(hPrinter, printBuffer, nRead, &nWritten) ;
>             rVal = 1 ;
>             CloseHandle(hFile) ;
>           }
>           else
>             rVal= -6 ;
>           EndPagePrinter(hPrinter) ;  // 28/11/2001 10:16
>         }
>         else
>           rVal = -4 ;
>         EndDocPrinter(hPrinter);
>       }
>       else
>         rVal= -3 ;
>       ClosePrinter(hPrinter) ;
>     }
>     else
>        rVal= -2 ;
>   }
>   return(rVal) ;
> }
>
>
Technical Details
Message-ID: <3fc77301@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail
References: <3fbcf9c2@newsgroups.borland.com> <3fbd8132$1@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,7b2449597708bec
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-11-28 08:09:24 PST
From: "John Scott" <jscott@kw.igs.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3fbcf9c2@newsgroups.borland.com> <3fbd8132$1@newsgroups.borland.com>
Subject: Re: Windows Printers
Date: Fri, 28 Nov 2003 11:07:37 -0500
Lines: 85
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1106
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 216.16.227.112
Message-ID: <3fc77301@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1070035713 216.16.227.112 (28 Nov 2003 08:08:33 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail