`
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! Printed November 23, 2024, 6:10 am This article has been viewed/printed 35250 times. Google search has resulted in 25 hits on this article since January 25, 2004. |