Article View: borland.public.cppbuilder.nativeapi
Article #11108Re: Print to File, But how?
From: Bob Gonder
Date: Fri, 27 Feb 2004 15:56
Date: Fri, 27 Feb 2004 15:56
42 lines
2435 bytes
2435 bytes
Eugene wrote:
>Thank you very much for your help, but i'm a newbie and i
>didn't hear EnumPrinters() before.So how can i use it with
>Borland C++ Builder 4.0? Can you give an example or show me a
>link for it? I couldnt find anything useful with googling?
It's listed in Win32.hlp, also listed at msdn.
http://msdn.microsoft.com/library/default.asp
Type EnumPrinters in the Search box.
>"JD" <nospam@nospam.com> wrote:
>>
>>Use EnumPrinters() to get the values for the "Generic - Text
>>Only" printer and use those values to fill in a PRINTER_INFO_2
>>structure. Then pass the structure to AddPrinter() and you get
>>a file-printer called "Generic" that is not the default printer
>>and is not shared.
I have no idea if this works or not, but I think this does what JD
said to do...
PRINTER_INFO_2 * pinfo2;
DWORD needed,returned;
EnumPrinters( PRINTER_ENUM_NAME, "Generic - Text Only",
2,NULL,0,&needed,&returned);
pinfo2 = (PRINTER_INFO_2*)malloc( needed );
EnumPrinters( PRINTER_ENUM_NAME, "Generic - Text Only",
2,pinfo2,needed,&needed,&returned);
This returns an array of 0 or more PRINTER_INFO_2
"returned" is the number of elements in the array.
for( i = 0; i < returned; i++ )
{ dosomethingwith( pinfo2[ i ] );
};
free( pinfo2 );
Don't forget to test for error returns, such as failure of the first
Enum.
Technical Details
Message-ID:
<nmou30t8dcb8phb05krrc2f4rmql0esqpp@4ax.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-mailReferences:
<403a01d6$1@newsgroups.borland.com> <403a74f3$1@newsgroups.borland.com> <403f60ad$1@newsgroups.borland.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,c183d0e61e81ac1b X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2004-02-27 08:10:45 PST From: Bob Gonder <notbg@notmindspring.invalid> Newsgroups: borland.public.cppbuilder.nativeapi Subject: Re: Print to File, But how? Date: Fri, 27 Feb 2004 07:56:41 -0800 Organization: MindSpring Enterprises, Inc. Reply-To: notbg@notmindspring.invalid Message-ID: <nmou30t8dcb8phb05krrc2f4rmql0esqpp@4ax.com> References: <403a01d6$1@newsgroups.borland.com> <403a74f3$1@newsgroups.borland.com> <403f60ad$1@newsgroups.borland.com> X-Newsreader: Forte Agent 1.93/32.576 English (American) MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit NNTP-Posting-Host: 67.31.166.85 X-Trace: newsgroups.borland.com 1077897403 67.31.166.85 (27 Feb 2004 07:56:43 -0800) Lines: 44 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