Meaning i am able to enum all printers (network and local) but ONLY if they are installed on my PC
However i want to be able to list those that are not installed and can be seen by using (windows built-in) ADD PRINTER dialog.
Is it even possible as i couldn't find anything useful browsing various forums/boards including stackexchange.
Meaning i tried the built-in .NET classes and WMI as well (SELECT * from Win32_Printer
) but obviously they list only the installed printers.
Thank you so much in advance
EDIT: please notice that suggested answer does not address non-installed printers but rather only installed ones. I am already able to list those. Thx
I do not believe there is anything in .NET that can do this, you will need to make a native call. Here is the MSDN page about how to enumerate network resources, what you will need to do is P/Invoke the
WNetEnumResource
function to getNETRESOURCE
objects back.You are looking for objects that have a
dwType
ofRESOURCETYPE_PRINT
, when you find them you checklpRemoteName
to get the name of the printer.Here is a link to a example snippet implementing its use (Even though the URL states it is VB the code is in C#). I would post it here but the note on the page expressly does not allow copying and pasting of the script without permission of the author.