[python-win32] printer identification on Windows network

Dean Allen Provins dprovins at tridentexploration.ca
Tue Oct 17 22:05:19 CEST 2006


Jürgen, Tim Golden and Tim Roberts:

Jürgen Kareta wrote:
> 
> 
> 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

Thank you for your very helpful replies.  I tried Jürgen's suggestions (above),
and the 1st and 3rd both worked flawlessly.

I sincerely appreciate your assistance.

Regards,

Dean

-- 
			   Dean Provins, P. Geoph.
		       dprovins at tridentexploration.ca
		         dprovins at alumni.ucalgary.ca
		  KeyID at at pgpkeys.mit.edu:11371: 0x9643AE65
	  Fingerprint: 9B79 75FB 5C2B 22D0 6C8C 5A87 D579 9BE5 9643 AE65



Confidentiality Notice:  The information transmitted herein may
contain confidential, proprietary and/or privileged material which
belongs to Trident Exploration Corp. and its affiliates and is
intended only for the addressee(s).  Any unauthorized review,
distribution or other use or the taking of any action in reliance
upon this information is prohibited.  If you received this email in
error, please contact the sender or call (403) 770-0333 and delete
this email and any copies.


More information about the Python-win32 mailing list