|
-
July 13th, 2012, 09:17 AM
#1
Get list of connected printers
Hi, I'm writing an application where I need to print out labels to a label printer. In my application I have it look for a printer with the name "DYMO Label Writer 450", and then use that printer. The problem I'm running in to is that if some how the printer's USB becomes unplugged and plugged back in, it might make a copy called "DYMO Label Writer 450 (Copy 1)". Now "DYMO Label Writer 450" is not connected so it won't work, and "DYMO Label Writer 450 (Copy 1)" is not equal to "DYMO Label Writer 450", so that won't work. Is it possible to get a list of all printers that are connected to the computer, and have it print to a printer name that contains "DYMO Label Writer 450" rather than being equal to it?
Here is the code I use to get the printer name and print:
Code:
try
{
PrintDocument printDoc = new PrintDocument();
// use the PrintDocument Class to Set the parameters
printDoc.PrinterSettings.PrinterName = "DYMO LabelWriter 450";
printDoc.DefaultPageSettings.Landscape = true;
if ("DYMO LabelWriter 450" != "***None***")
{
printDoc.PrintController = new System.Drawing.Printing.StandardPrintController();
printDoc.PrintPage += new PrintPageEventHandler(printDoc_Print);
printDoc.Print();
}
}
catch (Exception ex)
{
LogError(ex, "7");
}
Thank you.
- It's a long way to the top if you want to rock n' roll - AC/DC
Check out my band and support the music:
www.blueruinmusic.com
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|