🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Getting list of printers

#14857
From: JD
Date: Tue, 29 Jul 2003 00:50
30 lines
1776 bytes
"Luiz Rafael Culik Guimaraes" <culikr@uol.com.br> wrote:
> I need to get all printers(local and network) on an winxp
> machine(with printer name and printer port info)

Wouldn't it be enough to use the Printer()->Printers list?
If there exists a printer on the network that hasn't been
installed on the machine running the code, they can't use it
anyway.

Then you could iterate through the list of printers using
GetPrinter to get the rest of the info that you want:

    char  Buffer[ 256 * 3 ];
    char* Device = Buffer;
    char* Driver = Device + 256;
    char* Port   = Driver + 256;
    THandle hPrinter;

    for(int x = 0; x < Printer()->Printers->Count; ++x)
      {
      memset( Buffer, 0, 256 * 3 );
      Printer()->PrinterIndex = x;
      Printer()->GetPrinter( Device, Driver, Port, hPrinter );
      // do something with the info
      }

    Printer()->PrinterIndex = -1;

~ JD
Technical Details
Message-ID: <3f25c4d3$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3f254871@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,f542a59fe4cd92a4
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-07-28 17:57:32 PST
From: "JD" <nospam@nospam.com>
Sender: "JD" <nospam@nospam.com>
Reply-To: "JD" <nospam@nospam.com>
Subject: Re: Getting  list of printers
Newsgroups: borland.public.cppbuilder.nativeapi
X-User-Info: 172.155.212.53 172.155.212.53    
References:  <3f254871@newsgroups.borland.com>
NNTP-Posting-Host: 207.105.83.65
Message-ID: <3f25c4d3$1@newsgroups.borland.com>
Date: 28 Jul 2003 17:50:27 -0700
X-Trace: newsgroups.borland.com 1059439827 207.105.83.65 (28 Jul 2003 17:50:27 -0700)
Lines: 31
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-03!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail