Enumerating the installed printers

by Richard Russell, February 2014

The following program will list the installed printers:

        SYS "LoadLibrary", "WINSPOOL.DRV" TO winspool%
        SYS "GetProcAddress", winspool%, "EnumPrintersA" TO EnumPrinters%
 
        SYS EnumPrinters%, 6, 0, 4, 0, 0, ^needed%, ^returned%
        DIM buffer% needed%
        SYS EnumPrinters%, 6, 0, 4, buffer%, needed%, ^needed%, ^returned%
        IF returned% = 0 PRINT "No printers" : END
 
        FOR p% = 0 TO returned%-1
          PRINT $$!(buffer% + 12*p%)
        NEXT p%

The names displayed correspond to those which you need to use in the *PRINTER command, so this routine can be useful in avoiding the No such printer error.