Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Browsing network printers

Status
Not open for further replies.

kettch

Programmer
Mar 5, 2001
110
US
Is there a way to see all of the printers that are shared on a remote server programatically? I have tried just using the Directory and DirectoryInfo but it complains and says that the pathname must be \\server\share and i cant just look at \\server

I don't think that I am even going about this right, can anyone shed some light on this?
 
If the printer is installed, you can use the PrinterSettings.InstalledPrinters property, and get strings of each printer that is installed, here's a basic example of getting all installed printers on a computer, or network, and adding their respective strings to a combo box.

Note, this is a StringCollection( an array of read only strings), so it has to be retrieved via a string.
Only has a get, not a set.

foreach( string str in PrinterSettings.InstalledPrinters)
combobox.Items.Add(str);

You can use this information for a dialog box, or whatever else you need.


Remember, you can always

PrinterSettings.StringCollection sc = PrinterSettings.InstalledPrinters();

Then you can

sc.Count; //get the number of printers
sc[0]; //this would reference the 1st installed printer
sc[1]; //this would reference the 2nd installed printer.

Likewise, you can do:
PrinterSettings.InstalledPrinters.Count (not using a variable)

or
PrinterSettings.InstalledPrinters[1]; //reference the 2nd installed printer.

OR you could research the PrintDialog() .. the standard print dialog, which has a default value of ShowNetwork (which shows network printers) to be true.


Hope this is what you're looking for, if not, I'm sorry, but it's useful anyways :)

The weevil of doooooooooom
-The eagle may soar, but the weasel never gets sucked up by a jet engine (Anonymous)
 
I don't care about printers already installed, I have already incorporated that into the project.

I think the problem with the print dialog is that it involves user interaction which may, I don't know yet, or may not be OK.

Thanks for the tip though, I will look into it!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top