הערה
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות להיכנס או לשנות מדריכי כתובות.
הגישה לדף זה מחייבת הרשאה. באפשרותך לנסות לשנות מדריכי כתובות.
Question
Wednesday, May 23, 2012 3:13 PM
Is there a way to determine if a Printer exists? I want to warn my users that a printer doesn't exist before they send reports to print.
All replies (4)
Friday, May 25, 2012 5:49 AM ✅Answered | 1 vote
Hi Beruldsen,
Welcome to the MSDN forum.
Generally, we could use PrinterSettings.InstalledPrinters to list all installed printers on the computer. And then use PrinterSettings.IsValid property to check is this printer is valid.
Imports System.Drawing.Printing
Public Class Form2
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
Console.WriteLine(PrinterSettings.InstalledPrinters.Count.ToString & "Printers found")
Console.WriteLine("")
For Each ptName In PrinterSettings.InstalledPrinters
Dim pt As New PrinterSettings
pt.PrinterName = ptName
If pt.IsValid Then
Console.WriteLine("This Pritnter: " + ptName + " is available")
Console.WriteLine("Details:")
Console.WriteLine("Is default: " & pt.IsDefaultPrinter.ToString)
Console.WriteLine("Is plotter: " & pt.IsPlotter.ToString)
Console.WriteLine("")
End If
Next
End Sub
End Class
Moreover, you can use WMI to achieve this. There is a Win32_Printer class you can use.
If I misunderstood anything, please feel free and let me know.
Best regards,
Shanks Zen
MSDN Community Support | Feedback to us
Thursday, May 24, 2012 9:47 AM
Hi Beruldsen,
Welcome to the MSDN forum.
Could you please tell me if you want to build a project to do this?
What's the language you need to use?
With more details we can help to redirect you issue, this forum is only for Visual Studio Setup and Installation, not programming or common use.
Thanks,
Barry Wang [MSFT]
MSDN Community Support | Feedback to us
Thursday, May 24, 2012 1:18 PM
The application was developed in Vbnet. When a customer installs the application the reports generated by the application default to "Do Not Print"...however, in most cases the customer will change the print option to true. When they do this...I would like to check to see if a printer actually exists and warn them that no printer is currently connected.
Friday, May 25, 2012 3:24 AM
Hi Beruldsen,
In case your solution is using VB.NET, I will move your case to VB.net for better support.
Thanks,
Barry Wang [MSFT]
MSDN Community Support | Feedback to us