Retrieving icons associated with installed Printers for use in C# and WPF
-
I'm creating a ComboBox in my project that lists the installed Printers on my network. I have already been successful in creating the list and layout I wanted. But, I want to be able to display the same icons that you see next to them when you display your list in Vista or Windows 7. I have found a few articles online with people attempting the same thing but none that I have found have a real answer on how to go about this. Currently I am using System.Management to acquire all of the information I need about the installed Printers with the exception of course to the icons. Anyone have any suggestions on how to do this?
-
I'm creating a ComboBox in my project that lists the installed Printers on my network. I have already been successful in creating the list and layout I wanted. But, I want to be able to display the same icons that you see next to them when you display your list in Vista or Windows 7. I have found a few articles online with people attempting the same thing but none that I have found have a real answer on how to go about this. Currently I am using System.Management to acquire all of the information I need about the installed Printers with the exception of course to the icons. Anyone have any suggestions on how to do this?
Use SHGetFileInfo to enumerate the printers virtual directory.
-
Use SHGetFileInfo to enumerate the printers virtual directory.
Yeah I read one link with that on it but I've never done anything like that so don't have a clue how too.
-
I'm creating a ComboBox in my project that lists the installed Printers on my network. I have already been successful in creating the list and layout I wanted. But, I want to be able to display the same icons that you see next to them when you display your list in Vista or Windows 7. I have found a few articles online with people attempting the same thing but none that I have found have a real answer on how to go about this. Currently I am using System.Management to acquire all of the information I need about the installed Printers with the exception of course to the icons. Anyone have any suggestions on how to do this?
How to use the SHGetFileInfo function[^] is an example from MS on how to get associated icons. Good luck!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
-
How to use the SHGetFileInfo function[^] is an example from MS on how to get associated icons. Good luck!
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman
Wayne, thank you this will help me understand that a great deal. But, I am retrieving the installed printer information by using System.Management and querying Win32. I can simply add image references and display them next to those if that was all there was to it. But, I was wanting to know if there was a way when retrieving the list information to determine which image was being used to represent them or do I simply create that myself? If you open your devices and printers right now you will see a fax icon next to a fax, a printer next to a printer, and a networked printer icon next to a networked one. Is the information used to display the proper image able to be retrieved in the same manner as obtaining the printer list or do I have to setup some sort of code that can determine if the printer information received is a fax and have it display a fax image?
-
Wayne, thank you this will help me understand that a great deal. But, I am retrieving the installed printer information by using System.Management and querying Win32. I can simply add image references and display them next to those if that was all there was to it. But, I was wanting to know if there was a way when retrieving the list information to determine which image was being used to represent them or do I simply create that myself? If you open your devices and printers right now you will see a fax icon next to a fax, a printer next to a printer, and a networked printer icon next to a networked one. Is the information used to display the proper image able to be retrieved in the same manner as obtaining the printer list or do I have to setup some sort of code that can determine if the printer information received is a fax and have it display a fax image?
You get that info with SHGetFileInfo. It gives you the HICON back if you call it appropriately.