!-------------------------------------------------------------------------------------------- ! Ralf Schoeffler http://www.schoeffler.biz mailto:info@schoeffler.biz !-----------------------------snipp --------------------------------------------------------- ! inside the global map MODULE('WINAPI') EnumPrintersA(ULONG,*CSTRING,ULONG,*BYTE,ULONG,*ULONG,*ULONG),BOOL,PASCAL,RAW END !-------------------------------------------------------------------------------------------- !DATA flag ULONG pname CSTRING(255) level ULONG cbBuf ULONG cbBuffer STRING(65536) pcbNeed ULONG pcRetrun ULONG pPrinterEnum BYTE OVER(cbBuffer) ret LONG zeiger LONG,DIM(16384) OVER(cbBuffer) tstr STRING(250) tbyte BYTE pPrinter Queue Name STRING(32) Port STRING(60) SPrinter BYTE END !-------------------------------------------------------------------------------------------- !CODE flag = 2 ! PRINTER_ENUM_LOCAL pname = '' ! Cstring(255) level = 2 ! Printer_Info_2 cbBuf = 65536 ! Size of cbpBuffer pcbNeed = 0 ! Structur as bytes pcRetrun = 0 ! count of printers ret = EnumPrintersA(flag,pname,level,pPrinterEnum,cbBuf,pcbNeed,pcRetrun) loop p# = 0 to pcRetrun - 1 clear(pPrinter) !------------------------------------------------------------------------------------------- ! printername !------------------------------------------------------------------------------------------- tstr = '' loop i# = 0 to 32 peek(zeiger[2+(p#*21)]+i#, tbyte) if tbyte = 0 then break end tstr[i#+1] = chr(tbyte) end pPrinter:Name = tstr !------------------------------------------------------------------------------------------- ! Standard Printer !------------------------------------------------------------------------------------------- if clip(pPrinter:Name) = clip(PRINTER{PROPPRINT:Device}) then pPrinter:SPrinter = 1 end !------------------------------------------------------------------------------------------- ! Printerport !------------------------------------------------------------------------------------------- tstr = '' loop i#=0 to 32 peek(zeiger[4+(p#*21)]+i#,tbyte) if tbyte=0 then break end tstr[i#+1]=chr(tbyte) end pPrinter:Port = tstr pPrinters = pPrinter add(pPrinters) end !loop !-----------------------------snipp --------------------------------------------------------- !PRINTER_ENUM_LOCAL The function ignores the Name parameter, and enumerates the locally installed printers.Windows 95 only: The function will also enumerate network printers because they are handled by the local print provider. !PRINTER_ENUM_NAME The function enumerates the printer identified by Name. This can be a server, a domain, or a print provider. If Name is NULL, the function enumerates available print providers. !PRINTER_ENUM_SHARED The function enumerates printers that have the shared attribute. Cannot be used in isolation; use an OR operation to combine with another PRINTER_ENUM type. !PRINTER_ENUM_CONNECTIONS Windows NT only: The function enumerates the list of printers to which the user has made previous connections. !PRINTER_ENUM_NETWORK Windows NT only: The function enumerates network printers in the computer's domain. This value is valid only if Level is 1. !PRINTER_ENUM_REMOTE Windows NT only: The function enumerates network printers and print servers in the computer's domain. This value is valid only if Level is 1. !#define PRINTER_ENUM_DEFAULT 0x00000001 !#define PRINTER_ENUM_LOCAL 0x00000002 !#define PRINTER_ENUM_CONNECTIONS 0x00000004 !#define PRINTER_ENUM_FAVORITE 0x00000004 !#define PRINTER_ENUM_NAME 0x00000008 !#define PRINTER_ENUM_REMOTE 0x00000010 !#define PRINTER_ENUM_SHARED 0x00000020 !#define PRINTER_ENUM_NETWORK 0x00000040