🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: How to get windows default printer?

#14264
From: Richard Yu
Date: Tue, 19 Aug 2003 19:50
51 lines
2732 bytes
why the code give me 2 default printers ? (in control panel, I have 4
printer connected on the LAN,  when I set the param to PRINTER_ENUM_LOCAL,
the code can give me all the 4.), I thought it should be one. the s1 shows
the windows default printer, s is just another printer , how can I just get
the only window defaulter ?
I used the following code:

 char *buffer;
      char *s, *s1;

      buffer = (char *)malloc(PORT_BUF_SIZE);
      DWORD count, needed;
      EnumPrintersA(PRINTER_ENUM_CONNECTIONS |
PRINTER_ENUM_DEFAULT,//PRINTER_ENUM_LOCAL,
 NULL, 1, NULL, 0, &needed, &count);

      char *enumbuffer;
      enumbuffer = (char *)malloc(needed);
      EnumPrintersA(PRINTER_ENUM_CONNECTIONS | PRINTER_ENUM_DEFAULT,
file://PRINTER_ENUM_LOCAL
 NULL, 1, (LPBYTE)enumbuffer, needed, &needed, &count);
      PRINTER_INFO_1 *prinfo;

      prinfo = (PRINTER_INFO_1 *)enumbuffer;

      s = (char *)prinfo[0].pName;
      s1 = (char *)prinfo[1].pName;

"Remy Lebeau (TeamB)" <gambit47@yahoo.com> wrote in message
news:3f41597f$2@newsgroups.borland.com...
>
> "Richard Yu" <richard@colorselector.com> wrote in message
> news:3f415360$1@newsgroups.borland.com...
> > How to get Win default printer name and port ,
>
> Use EnumPrinters() with the flags parameter set to PRINTER_ENUM_DEFAULT.
If
> EnumPrinters() fails to find the printer, then fallback to looking at the
> "device" value in the "windows" section of the system's WIN.INI file.
>
>
> Gambit
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.510 / Virus Database: 307 - Release Date: 8/14/03
>
>
Technical Details
Message-ID: <3f427f92$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail
References: <3f415360$1@newsgroups.borland.com> <3f41597f$2@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 10cc67,16abfae200d036ee
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-08-19 12:53:25 PST
From: "Richard Yu" <richard@colorselector.com>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3f415360$1@newsgroups.borland.com> <3f41597f$2@newsgroups.borland.com>
Subject: Re: How to get windows default printer?
Date: Tue, 19 Aug 2003 12:50:34 -0700
Lines: 53
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 5.50.4522.1200
X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4522.1200
NNTP-Posting-Host: 24.207.7.224
Message-ID: <3f427f92$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1061322642 24.207.7.224 (19 Aug 2003 12:50:42 -0700)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-04!sn-xit-06!sn-xit-08!supernews.com!border3.nntp.aus1.giganews.com!border1.nntp.aus1.giganews.com!nntp.giganews.com!nntp-relay.ihug.net!newsfeeds.ihug.co.nz!ihug.co.nz!newsgroups.borland.com!not-for-mail