Article View: borland.public.cppbuilder.nativeapi
Article #14855Re: Getting list of printers
From: Luiz Rafael Culik Guimaraes
Date: Mon, 28 Jul 2003 20:24
Date: Mon, 28 Jul 2003 20:24
77 lines
3015 bytes
3015 bytes
Hi vladmir
> Can you put your code here?
here is it
On win98/WinMe/Win95 it show all printer properly
#define 60
HB_FUNC(GETPRINTERS)
{
unsigned char *buffer;
unsigned long needed = 0 , returned , a ;
BOOL res;
char * Printer[MAX_PRINTER];
buffer = ( unsigned char * ) malloc( MAX_PRINTERS * sizeof(
PRINTER_INFO_5 ) ) ;
res = EnumPrinters( PRINTER_ENUM_NETWORK | PRINTER_ENUM_LOCAL |
PRINTER_ENUM_CONNECTIONS ,
NULL ,
5 ,
buffer ,
MAX_PRINTERS * sizeof( PRINTER_INFO_5 ) ,
&needed ,
&returned );
if( !res )
{
if( GetLastError() != ERROR_INSUFFICIENT_BUFFER )
return NULL;
else {
free(buffer) ;
buffer = ( unsigned char * ) malloc( needed ) ;
res=EnumPrinters(PRINTER_ENUM_NETWORK | PRINTER_ENUM_LOCAL|
PRINTER_ENUM_CONNECTIONS ,
NULL ,
5 ,
buffer ,
needed ,
&needed ,
&returned );
}
}
if( !res )
return NULL;
for ( a = 0 ; a < returned ; a++ ){
PHB_ITEM pSubItems = hb_itemArrayNew( 2 );
PHB_ITEM pFile = hb_itemPutC( NULL, ( ( PRINTER_INFO_5 * ) (
buffer + sizeof( PRINTER_INFO_5 ) * a ) )->pPrinterName );
PHB_ITEM pPort = hb_itemPutC( NULL,( ( PRINTER_INFO_5 * ) ( buffer
+ sizeof( PRINTER_INFO_5 ) * a ) )->pPortName );
this part put all printers in an Array for returning
}
//Return the printer array
}
> All lost printers are published?
Yes on my network
> Do you see all these in "Network" on your PC?
yes
> Do you tried to obtain this list another way,
> for example via Windows Script:
>
http://www.microsoft.com/technet/treeview/default.asp?url=/technet/scriptcenter/printing/ScrPrn14.asp
I cant use windows script becouse of security issue
Regards
Luiz
Technical Details
Message-ID:
<3f2586d3@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mailReferences:
<3f25483b$1@newsgroups.borland.com> <3f255ac6$1@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 13:40:31 PST From: "Luiz Rafael Culik Guimaraes" <culikr@uol.com.br> Newsgroups: borland.public.cppbuilder.nativeapi References: <3f25483b$1@newsgroups.borland.com> <3f255ac6$1@newsgroups.borland.com> Subject: Re: Getting list of printers Date: Mon, 28 Jul 2003 17:24:25 -0300 Lines: 79 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1158 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165 NNTP-Posting-Host: 200.203.17.172 Message-ID: <3f2586d3@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1059423955 200.203.17.172 (28 Jul 2003 13:25:55 -0700) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!news.tele.dk!news.tele.dk!small.news.tele.dk!npeer.de.kpn-eurorings.net!newsfeed00.sul.t-online.de!newsfeed01.sul.t-online.de!t-online.de!newsgroups.borland.com!not-for-mail