Login
`
Templates, Tools and Utilities
|
||
Add a comment to an Icetips ArticlePlease add your comments to this article.
Please note that you must provide both a name and a valid email address in order
for us to publish your comment. Comments are moderated and are not visible until they have been approved. Spam is never approved!
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!
Today is November 23, 2024, 3:27 am This article has been viewed 35250 times. Google search has resulted in 25 hits on this article since January 25, 2004.
|
|