[python-win32] printer identification on Windows network
Jürgen Kareta
python at kareta.de
Tue Oct 17 18:27:44 CEST 2006
Hello Dean,
>I am not a Windows programmer, but have managed to port some Linux codes to the
>python/windows environment. To allow windows users to print, I used some code
>that needed to know the name of the 'shares' providing printers (there were 2 of
>them in the environment in which I work). The code looks in part like:
>
> import win32print
> default_printer = win32print.GetDefaultPrinter () # just the default
>
> for j in range (len (self.share_names)): # <-------must know share names!
> A = win32print.EnumPrinters (win32print.PRINTER_ENUM_NAME,\
> self.share_names [j], 2)
> for i in range (len (A)):
> win_printer = A [i] ['pPrinterName']
> self.printer_list.append (win_printer)
>
>My question then is, "how does one determine the share names in an arbitrary
>environment - without asking someone, and then coding them (as I've done above?)"
>
>
>
try win32print.EnumPrinters(win32print.PRINTER_ENUM_LOCAL,None,2) or
win32print.EnumPrinters(win32print.PRINTER_INFO,None,2) for lokal shares
and
win32print.EnumPrinters(100,None,2) for network shares. Further Infos
look up at:
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_9fjn.asp
Hope this helps,
regards,
Jürgen
More information about the Python-win32
mailing list