` Enumerating Printers (Lee White) - Icetips Article
Icetips - Templates, Tools & Utilities for Clarion Developers

Templates, Tools and Utilities
for Clarion Developers

Icetips Article

Back to article list   Search Articles     Add Comment     Printer friendly     Direct link  

Windows API: Enumerating Printers
2005-02-08 -- Lee White
 
Newsgroups: comp.lang.clarion > How can one get all printers available from print setup loaded into > a que or > table.. Windows API, EnumPrinters() http://msdn.microsoft.com/library/default.asp?url=/library/en-us/gdi/prntspol_9fjn.asp You call it twice, once to get the memory required and printer count, then again to load that memory. Although I use HeapCreate & HeapAlloc, you should be able to create the memory by NEWing a string to the proper size. Use PRINTER_ENUM_LOCAL + PRINTER_ENUM_CONNECTIONS to get the printer list of all local printers and any network printers defined for the user. For NT/2000/XP use PRINTER_INFO_4. For '9x/Me use PRINTER_INFO_5. Once you get the memory loaded you can loop through it and use memcpy to carve out chunks to fit the size of the INFO group. The use the pointers from the group and lstrcpyn to get the information into a queue. Just be careful with your coding so you don't create any buffer overflows with lstrcpyn! And you thought this would be hard! Look around, there's probably a free template somewhere to do this for you. -- Lee White


Today is April 25, 2024, 3:07 pm
This article has been viewed 35124 times.
Google search has resulted in 25 hits on this article since January 25, 2004.



Back to article list   Search Articles   Add Comment   Printer friendly

Login

User Name:

Password: